Skip to content

esm: top-level Wasm without package type #57610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

guybedford
Copy link
Contributor

We currently support node x.wasm through the ESM integration where .wasm files are located inside packages with "type": "module", but not without the module type on the package. This fixes the top-level execution case to always use the ESM loader.

This fix also adds a comprehensive test case for top-level Wasm execution that in turn can be extended to various end-to-end Wasm execution scenarios, in this example creating a JS object, setting some properties on it, and logging it back.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Mar 25, 2025
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

wasm should definitely work regardless of the presence or value of the type setting 🚀

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (1c2d98d) to head (98d440a).
Report is 299 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57610      +/-   ##
==========================================
+ Coverage   90.22%   90.24%   +0.01%     
==========================================
  Files         630      630              
  Lines      185073   185074       +1     
  Branches    36222    36226       +4     
==========================================
+ Hits       166990   167017      +27     
+ Misses      11044    11031      -13     
+ Partials     7039     7026      -13     
Files with missing lines Coverage Δ
lib/internal/modules/run_main.js 97.61% <100.00%> (+0.01%) ⬆️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GeoffreyBooth
Copy link
Member

Is there any documentation that needs updating?

@GeoffreyBooth GeoffreyBooth added the notable-change PRs with changes that should be highlighted in changelogs. label Mar 25, 2025
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @GeoffreyBooth.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

@ljharb ljharb added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 25, 2025
@guybedford
Copy link
Contributor Author

According to the existing ESM_FILE_FORMAT spec, the package.json type shouldn't affect the .wasm Wasm interpretation, so I don't think we need to make any changes to the docs as this is what's already described.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@richardlau
Copy link
Member

Is there any documentation that needs updating?

Maybe https://nodejs.org/docs/latest/api/cli.html#program-entry-point?

@guybedford
Copy link
Contributor Author

Maybe https://nodejs.org/docs/latest/api/cli.html#program-entry-point?

Good point, I've updated that section to match the current implementation.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

guybedford added a commit that referenced this pull request Apr 4, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
@guybedford
Copy link
Contributor Author

Landed in 870dec2.

@guybedford guybedford closed this Apr 4, 2025
JonasBa pushed a commit to JonasBa/node that referenced this pull request Apr 11, 2025
PR-URL: nodejs#57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
RafaelGSS pushed a commit that referenced this pull request May 1, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
RafaelGSS pushed a commit that referenced this pull request May 2, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
@aduh95 aduh95 added baking-for-lts PRs that need to wait before landing in a LTS release. and removed baking-for-lts PRs that need to wait before landing in a LTS release. labels May 6, 2025
aduh95 pushed a commit that referenced this pull request May 6, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
RafaelGSS pushed a commit that referenced this pull request May 14, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
aduh95 pushed a commit that referenced this pull request May 17, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
nodejs-github-bot added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 pushed a commit that referenced this pull request May 19, 2025
PR-URL: #57610
Reviewed-By: Jordan Harband 
Reviewed-By: Geoffrey Booth 
Reviewed-By: Matteo Collina 
Reviewed-By: Antoine du Hamel 
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: TODO
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 added a commit to aduh95/node that referenced this pull request May 20, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) nodejs#57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) nodejs#58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) nodejs#57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) nodejs#58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) nodejs#57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) nodejs#57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) nodejs#57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) nodejs#57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) nodejs#57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) nodejs#57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) nodejs#57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) nodejs#57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) nodejs#57888

PR-URL: nodejs#58388
aduh95 added a commit that referenced this pull request May 21, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants