Skip to content
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

esm: top-level Wasm without package type #57610

Open
wants to merge 3 commits into
base: main
Choose a base branch
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 (1123585) to head (0cdb8f0).
Report is 2 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      185055   185056       +1     
  Branches    36216    36222       +6     
==========================================
+ Hits       166975   166995      +20     
+ Misses      11042    11034       -8     
+ Partials     7038     7027      -11     
Files with missing lines Coverage Δ
lib/internal/modules/run_main.js 97.61% <100.00%> (+0.01%) ⬆️

... and 22 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.

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