Skip to content

Conversation

@joyeecheung
Copy link
Member

This adds a embedder_module_hdo for identifying embedder-run modules in the dynamic import handler and import.meta initializer, and a SourceTextModuleTypes for customizing source text module compilation in the JS land via compileSourceTextModule(). Also, refactors the existing embedder module compilation code to reuse the builtin resolution logic.

This adds a embedder_module_hdo for identifying embedder-run
modules in the dynamic import handler and import.meta initializer,
and a SourceTextModuleTypes for customizing source text module
compilation in the JS land via compileSourceTextModule().
Also, refactors the existing embedder module compilation code
to reuse the builtin resolution logic.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/vm

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Feb 3, 2026
v8::Local<v8::Context> context = isolate_->GetCurrentContext();
// Finish the await.
context->GetMicrotaskQueue()->PerformCheckpoint(isolate_);
v8::Local<v8::Value> imported_value = result.As<v8::Promise>()->Result();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
v8::Local<v8::Value> imported_value = result.As<v8::Promise>()->Result();
EXPECT_EQ(result.As<v8::Promise>()->State(), v8::Promise::kFulfilled);
v8::Local<v8::Value> imported_value = result.As<v8::Promise>()->Result();

// Finish the await.
context->GetMicrotaskQueue()->PerformCheckpoint(isolate_);

v8::Local<v8::Value> imported_value =
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
v8::Local<v8::Value> imported_value =
EXPECT_EQ(result.As<v8::Promise>()->State(), v8::Promise::kFulfilled);
v8::Local<v8::Value> imported_value =

kInternal: 'internal', // TODO(joyeecheung): support internal ESM.
kEmbedder: 'embedder', // Embedder ESM, also used by SEA
kUser: 'user', // User-land ESM
kDynamic: 'dynamic', // Currently only used by the facade that proxies WASM module import/exports.
Copy link
Member

Choose a reason for hiding this comment

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

I feel like the term dynamic in ESM could be related to the dynamic import calls. Given that this creates a module with a facade, and this is also not a synthetic module, maybe we should rename it to a facade module.

Nevertheless, this is not a blocker for this PR.

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 98.61111% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.75%. Comparing base (8e41b8d) to head (6d557b8).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/modules/esm/utils.js 96.96% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #61654   +/-   ##
=======================================
  Coverage   89.74%   89.75%           
=======================================
  Files         674      674           
  Lines      204348   204431   +83     
  Branches    39271    39277    +6     
=======================================
+ Hits       183396   183480   +84     
+ Misses      13262    13255    -7     
- Partials     7690     7696    +6     
Files with missing lines Coverage Δ
lib/internal/main/embedding.js 87.50% <100.00%> (+2.41%) ⬆️
lib/internal/modules/esm/create_dynamic_module.js 96.00% <100.00%> (+0.08%) ⬆️
lib/internal/modules/esm/loader.js 96.97% <100.00%> (+<0.01%) ⬆️
lib/internal/modules/esm/translators.js 92.37% <100.00%> (-0.21%) ⬇️
lib/internal/modules/helpers.js 98.49% <100.00%> (+0.32%) ⬆️
src/module_wrap.cc 74.23% <100.00%> (+0.02%) ⬆️
src/node_contextify.cc 82.63% <100.00%> (+0.17%) ⬆️
lib/internal/modules/esm/utils.js 99.50% <96.96%> (-0.50%) ⬇️

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

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants