Skip to content

wasm: support js string constant esm import#62198

Open
guybedford wants to merge 3 commits intonodejs:mainfrom
guybedford:add-imported-string-constants-test
Open

wasm: support js string constant esm import#62198
guybedford wants to merge 3 commits intonodejs:mainfrom
guybedford:add-imported-string-constants-test

Conversation

@guybedford
Copy link
Contributor

This adds support for the new wasm:js/string-constants import for the ESM integration as recently landed per the latest spec in WebAssembly/esm-integration#115.

With this it is now possible to import constant JS strings in both the instance and source Wasm phases.

Example usage:

(module
  (import "wasm:js-string" "cast"
    (func $cast (param externref) (result (ref extern))))
  (import "wasm:js-string" "concat"
    (func $concat (param externref externref) (result (ref extern))))
  (import "wasm:js/string-constants" "Hello "
    (global $hello (ref extern)))

  (func (export "greet") (param $name externref) (result externref)
    (call $concat
      (global.get $hello)
      (call $cast (local.get $name))))
)

Extends the Wasm ESM Integration for importing WebAssembly
modules in either the source phase or instance phase to support
importing static JS string constants from the special
import name `wasm:js/string-constants`.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.65%. Comparing base (9ff27fd) to head (98a6cb3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62198      +/-   ##
==========================================
+ Coverage   89.63%   89.65%   +0.01%     
==========================================
  Files         676      676              
  Lines      206578   206579       +1     
  Branches    39555    39562       +7     
==========================================
+ Hits       185171   185206      +35     
+ Misses      13535    13486      -49     
- Partials     7872     7887      +15     
Files with missing lines Coverage Δ
lib/internal/modules/esm/translators.js 97.66% <100.00%> (+<0.01%) ⬆️

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

Co-authored-by: James Sumners <jsumners@newrelic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants