Skip to content

Allow initializing WASM contents in Node.js - #532

Open
Hanabi9248 wants to merge 4 commits into
mozilla:masterfrom
Hanabi9248:codex/node-wasm-initialize
Open

Hanabi9248 wants to merge 4 commits into
mozilla:masterfrom
Hanabi9248:codex/node-wasm-initialize

Conversation

@Hanabi9248

Copy link
Copy Markdown

Fixes #527.

SourceMapConsumer.initialize() ignores supplied WASM bytes in Node.js, so a bundle still tries to read mappings.wasm next to the relocated module.

Use a supplied ArrayBuffer when available, keeping the filesystem loader as the default. The README and API comments now describe this Node.js behavior. Callers must initialize before constructing consumers; an existing WASM instance is not replaced.

The regression test starts a fresh process, makes filesystem loading fail, and checks a source position using the real WASM. It fails before this change and passes afterward. Separate tests cover the supplied bytes and default loader.

Tested on Windows with Node.js v24.19.0:

  • node test/run-tests.js: 193/193 passed.
  • ESLint on the changed JavaScript files: passed.

@Hanabi9248

Copy link
Copy Markdown
Author

Following up on the Node.js bundling case in #527: would supporting explicitly supplied WASM bytes through initialize() fit the API direction? This keeps filesystem loading as the default and tests the bundled case in a fresh process with filesystem loading disabled. I’d appreciate feedback when you have time.

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.

allow wasm to be bundled

1 participant