Skip to content

module: enable existing machinery for deferred imports#63712

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
MayaLekova:import-defer-01
Jun 16, 2026
Merged

module: enable existing machinery for deferred imports#63712
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
MayaLekova:import-defer-01

Conversation

@MayaLekova

Copy link
Copy Markdown
Contributor

This commit enables deferred module imports by using the corresponding functionality in V8. It also adds a single test, but more test coverage should be added.

Refs: https://github.com/tc39/proposal-defer-import-eval

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/vm

@MayaLekova MayaLekova changed the title module: enable existing machinery for import defer module: enable existing machinery for deferred imports Jun 2, 2026
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Jun 2, 2026

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the commit message needs to clarify that this only makes it work for static import, but not dynamic import yet?

Comment thread test/fixtures/es-modules/module-deferred-eval.mjs
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.35%. Comparing base (6813080) to head (6bb2db9).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #63712    +/-   ##
========================================
  Coverage   90.34%   90.35%            
========================================
  Files         732      732            
  Lines      236580   236709   +129     
  Branches    44545    44585    +40     
========================================
+ Hits       213748   213870   +122     
- Misses      14536    14565    +29     
+ Partials     8296     8274    -22     
Files with missing lines Coverage Δ
src/module_wrap.cc 74.41% <100.00%> (+0.04%) ⬆️
src/module_wrap.h 52.94% <ø> (ø)

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

@MayaLekova

Copy link
Copy Markdown
Contributor Author

Thank you, I moved the test, but should I add more extensive test coverage, even for static imports?

@joyeecheung

joyeecheung commented Jun 4, 2026

Copy link
Copy Markdown
Member

I think a smoke test is enough. The rest should be covered by test262 in the upstream.

Can you rewrap the commit message to 72 chars to make the linter happy? Also this needs adding a eslint plugin

2026-06-03T13:01:48.8039114Z /home/runner/work/node/node/test/es-module/test-defer-import-eval.mjs
2026-06-03T13:01:48.8044324Z 10:7 error Parsing error: This experimental syntax requires enabling the parser plugin: "deferredImportEvaluation". (10:7)

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing!

@MayaLekova MayaLekova force-pushed the import-defer-01 branch 3 times, most recently from 2915765 to bd9968c Compare June 8, 2026 15:08
Comment thread src/module_wrap.h

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works perfectly thank you!

@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread test/es-module/test-defer-import-eval.mjs Outdated
Comment thread test/es-module/test-defer-import-with-module-tree.mjs Outdated
@MayaLekova

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews! Do you mind checking the updated version? (minor changes in tests only)
@joyeecheung @guybedford

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test looks good. It would be great to see a Wasm test too (import defer * as foo from './foo.wasm'), but that also isn't necessary either.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 10, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

This commit enables deferred import for statically imported modules,
by using the corresponding functionality in V8. It adds two tests:
 - smoke test exercising the basic syntax
 - test for deferred import of module with its own imports

More test coverage should be added for mixing ESM and CJS modules,
as well as TypeScript modules.

Refs: https://github.com/tc39/proposal-defer-import-eval
Signed-off-by: Maya Lekova <maya@igalia.com>
@joyeecheung joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@guybedford guybedford added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 16, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 16, 2026
@nodejs-github-bot nodejs-github-bot merged commit b09155d into nodejs:main Jun 16, 2026
73 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in b09155d

@MayaLekova

Copy link
Copy Markdown
Contributor Author

Test looks good. It would be great to see a Wasm test too (import defer * as foo from './foo.wasm'), but that also isn't necessary either.

Thank you for helping me land this PR!

I'll add more tests in the next commits, including some with Wasm modules.

aduh95 pushed a commit that referenced this pull request Jun 18, 2026
This commit enables deferred import for statically imported modules,
by using the corresponding functionality in V8. It adds two tests:
 - smoke test exercising the basic syntax
 - test for deferred import of module with its own imports

More test coverage should be added for mixing ESM and CJS modules,
as well as TypeScript modules.

Refs: https://github.com/tc39/proposal-defer-import-eval
Signed-off-by: Maya Lekova <maya@igalia.com>
PR-URL: #63712
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants