Skip to content

fix(core): keep Node's format for data: URL imports - #852

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/issue-841
Oct 16, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/issue-841

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Member

Closes #841

Problem

The resolve hook short-circuited data: specifiers with the format builtin. Node.js then looked the URL up as a built-in module, so every data: import failed:

Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: data:text/javascript,export const v = 7

Fix

The data: branch still short-circuits, but now passes no format, so add_short_circuit keeps the format Node.js' nextResolve derives from the MIME type. The load hook already leaves data: URLs to Node.js.

Tests

packages/integrate-vitest/__tests__/data-urls.spec.ts covers:

  • static and dynamic text/javascript imports
  • a base64 text/javascript import
  • an application/json import with type: 'json'
  • text/plain, which still fails with ERR_UNKNOWN_MODULE_FORMAT, as in plain Node.js

The test fails on main at the first import with ERR_UNKNOWN_BUILTIN_MODULE.

Verification (macOS arm64, Node 24.22)

The same script prints the same output under plain node, node --import @oxc-node/core/register and the CLI, including uppercase DATA:. cargo test --all-features, cargo clippy --all-targets --all-features -- -D warnings, vp run test (217 passed) and vp run lint all pass.

πŸ€– Generated with Claude Code

The resolve hook short-circuited `data:` specifiers with the format
`builtin`, so Node.js looked the URL up as a built-in module and every
`data:` import failed with ERR_UNKNOWN_BUILTIN_MODULE. Keep the format
Node.js derives from the MIME type instead.

Closes #841

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
πŸ“ Code Review βœ… Completed 2026-10-16T09:46:27.511129Z 6846e09 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with πŸ‘€ while any review is running, comments if it has suggestions, and reacts with πŸ‘ once all reviews finish with no findings.

With a `registerHooks()` load hook in the chain, Node.js rejects its own
`null` format for an unknown `data:` MIME type as
ERR_INVALID_RETURN_PROPERTY_VALUE instead of ERR_UNKNOWN_MODULE_FORMAT;
a pass-through JavaScript hook does the same. The test only needs the
import to fail.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn
Brooooooklyn merged commit 23031bf into main Oct 16, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/issue-841 branch October 16, 2026 12:40
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.

data: URL imports fail with ERR_UNKNOWN_BUILTIN_MODULE

1 participant