Skip to content

Use node: prefixes for Node builtins - #24

Merged
hyfdev merged 1 commit into
mainfrom
agent/node-builtin-prefixes
Aug 16, 2026
Merged

hyfdev merged 1 commit into
mainfrom
agent/node-builtin-prefixes

Conversation

@hyfdev

@hyfdev hyfdev commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • normalize Node builtin specifiers in the napi-rs-generated native loader before formatting and bundling
  • enforce node: for authored code with Oxlint and cover the public package entry with a regression test
  • record the vouched repository-wide Node builtin protocol rule

Root cause

@napi-rs/cli@3.8.2 intentionally emits bare module, fs, and child_process specifiers to keep its loader compatible with Node 12. TaffyJS requires Node 22.18 or newer, so that compatibility tradeoff is unnecessary here, and the bare module entry fails Deno 2.2.15's default resolution.

The build now normalizes the generated artifact at the repository-owned boundary instead of patching the dependency. This change does not declare Deno or Bun support; it enforces the package artifact's node: builtin convention.

Tests

  • vp run ready
  • pnpm dlx deno@2.2.15 eval --node-modules-dir=manual 'await import("@taffyjs/node")'
  • pnpm dlx bun@1.2.15 -e 'await import("@taffyjs/node")'

@hyfdev
hyfdev marked this pull request as ready for review August 16, 2026 10:12
Copilot AI lite review requested due to automatic review settings August 16, 2026 10:12
@hyfdev
hyfdev merged commit dbdad1e into main Aug 16, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request standardizes Node.js builtin module specifiers to use the explicit node: protocol across the @taffyjs/node build outputs and repository code, addressing generated-loader bare specifiers and enforcing the convention via linting, tests, and PCR documentation.

Changes:

  • Adds an Oxlint rule to enforce node: protocol for Node builtin imports in authored code.
  • Introduces a build step to normalize builtin specifiers in the napi-rs–generated binding.js before formatting/bundling.
  • Adds a regression test to ensure the public @taffyjs/node entry contains no bare builtin specifiers, and records the repository-wide rule in PCR docs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vite.config.ts Adds unicorn/prefer-node-protocol and inserts a normalization task into the Node build graph before formatting.
tools/taffy-node/normalize-node-builtin-specifiers.ts New script that rewrites bare builtin specifiers in the generated native loader to node: and asserts none remain.
tests/taffyjs-node/tests/package/node-builtin-specifiers.test.mts New regression test scanning the public package entry for bare builtin import/require patterns.
packages/taffyjs-node/index.js Updates builtin references to use node: protocol in the distributed entry output.
packages/taffyjs-node/binding.js Updates generated loader’s builtin imports/requires to use node: protocol.
.agents/docs/tooling-decisions.md Records and vouches the repository-wide “Node builtin module protocol” rule in the tooling decisions ledger.
.agents/docs/technology-stack.md Documents the normalization step as part of the native loader build pipeline and the Node target constraints.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +14 to +17
const bareBuiltinReference = new RegExp(
String.raw`(?:\bfrom\s+|\bimport\s+|\brequire(?:\.resolve)?\s*\(\s*|\bimport\s*\(\s*)(["'])(${bareBuiltinAlternatives})\1`,
"g",
);
hyfdev added a commit that referenced this pull request Aug 16, 2026
Normalize Node builtin imports and add runtime smoke coverage for the implemented packages.

Refs: #24, #25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants