Skip to content

module: add tests for two cases of eager imports:#64197

Open
MayaLekova wants to merge 1 commit into
nodejs:mainfrom
MayaLekova:import-defer-02
Open

module: add tests for two cases of eager imports:#64197
MayaLekova wants to merge 1 commit into
nodejs:mainfrom
MayaLekova:import-defer-02

Conversation

@MayaLekova

Copy link
Copy Markdown
Contributor
  • when the defer imported module contains top-level await
  • when the defer imported module is eagerly imported from another module

Refs: https://github.com/tc39/proposal-defer-import-eval
Signed-off-by: Maya Lekova maya@igalia.com

  - when the defer imported module contains top-level await
  - when the defer imported module is eagerly imported from another module

Refs: https://github.com/tc39/proposal-defer-import-eval
Signed-off-by: Maya Lekova <maya@igalia.com>
@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. test Issues and PRs related to the tests. labels Jun 29, 2026

@nicolo-ribaudo nicolo-ribaudo 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.

Note that this is already tested in test262:

I am not super familiar with the Node.js implementation of ESM, but test262 is run through V8's d8.

Whether or not it makes sense to have these two tests here probably depends on how much they are testing V8-internal code paths vs if there is any part of it that is implemented on the Node.js side.


The tests look correct :)

export const foo = 42;

await setTimeout(1);
console.log('executed');

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.

Should this also push to eval_list rather than logging?

// Check that the module has already been evaluated.
assert.strictEqual(globalThis.eval_list.length, 1);
assert.strictEqual(ns.foo, 42);
assert.partialDeepStrictEqual(['defer-tla-1'], globalThis.eval_list);

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.

Also assert the length after the ns.foo access.

@nicolo-ribaudo

Copy link
Copy Markdown
Contributor

Oh, could you update the commit first line to mention that it's about import defer?

@joyeecheung

joyeecheung commented Jun 29, 2026

Copy link
Copy Markdown
Member

This doesn't look very Node.js specific and should live in test262 instead? As long as the V8 side works alright I think it's unlikely that anything in particular in Node.js would make it not work.

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. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants