Skip to content

wasm: support js string constant esm import#62198

Open
guybedford wants to merge 1 commit intonodejs:mainfrom
guybedford:add-imported-string-constants-test
Open

wasm: support js string constant esm import#62198
guybedford wants to merge 1 commit 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.63%. Comparing base (9ff27fd) to head (dbe5977).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62198      +/-   ##
==========================================
- Coverage   89.63%   89.63%   -0.01%     
==========================================
  Files         676      676              
  Lines      206578   206579       +1     
  Branches    39555    39556       +1     
==========================================
- Hits       185171   185162       -9     
- Misses      13535    13536       +1     
- Partials     7872     7881       +9     
Files with missing lines Coverage Δ
lib/internal/modules/esm/translators.js 97.66% <100.00%> (+<0.01%) ⬆️

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

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.

3 participants