Skip to content

[deferred-reexports] Add load-and-evaluation tests#5034

Open
caiolima wants to merge 1 commit intotc39:mainfrom
caiolima:export-defer-load-and-evaluation
Open

[deferred-reexports] Add load-and-evaluation tests#5034
caiolima wants to merge 1 commit intotc39:mainfrom
caiolima:export-defer-load-and-evaluation

Conversation

@caiolima
Copy link
Copy Markdown
Contributor

Covers the "Load and Evaluation" section of #5010 for the deferred re-exports proposal (https://tc39.es/proposal-deferred-reexports/).

This adds 7 scenarios under test/language/export/export-defer/load-and-evaluation:

  1. no-consumer-no-load: export defer { x } from dep does not load dep when nothing consumes x.
  2. consumer-imports-loads: an import of the deferred binding loads and evaluates its source.
  3. chained-defer: a chain of deferred re-exports evaluates every link on the chain when the binding is consumed.
  4. reexport-non-defer-consumed: a plain (non-defer) re-export of a deferred binding forces its source to load when the entrypoint consumes it.
  5. reexport-non-defer-unconsumed: a plain (non-defer) re-export of a deferred binding forces its source to load even when the entrypoint does not consume it.
  6. star-reexport-non-default: export * over a module with a deferred non-default re-export pulls the deferred source.
  7. star-reexport-default: export * (ALL-BUT-DEFAULT) skips a deferred default re-export, leaving its source unlinked.

Tests that observe evaluation order populate a shared globalThis.evaluations array from each fixture and assert via assert.compareArray (following previous tests from import-defer). Tests that prove a module is not loaded point at a dependency containing invalid syntax! paired with a positive signal (a marker binding, or evaluation order tracking) to assert that the module was properly executed, but unused optional re-exports were skipped.

Covers the "Load and Evaluation" section of tc39#5010 for the
deferred re-exports proposal (https://tc39.es/proposal-deferred-reexports/).

Seven scenarios under test/language/export/export-defer/load-and-evaluation/:

  1. no-consumer-no-load: `export defer { x } from dep` does not load dep
     when nothing consumes x.
  2. consumer-imports-loads: an import of the deferred binding loads and
     evaluates its source.
  3. chained-defer: a chain of deferred re-exports evaluates every link on
     the chain when the binding is consumed.
  4. reexport-non-defer-consumed: a plain (non-defer) re-export of a
     deferred binding forces its source to load when the entrypoint consumes
     it.
  5. reexport-non-defer-unconsumed: a plain (non-defer) re-export of a
     deferred binding forces its source to load even when the entrypoint
     does not consume it.
  6. star-reexport-non-default: `export *` over a module with a deferred
     non-default re-export pulls the deferred source.
  7. star-reexport-default: `export *` (ALL-BUT-DEFAULT) skips a deferred
     default re-export, leaving its source unlinked.

Tests that observe evaluation order populate a shared globalThis.evaluations
array from each fixture and assert via assert.compareArray (following
previous tests from import-defer). Tests that prove a module is not loaded
point at a dep containing `invalid syntax!` paired with a positive signal
(a `marker` binding, or evaluations tracking) to assert that the module
was properly executed, but unused optional re-exports were skipped.
@caiolima caiolima requested a review from a team as a code owner April 16, 2026 12:48
@nicolo-ribaudo nicolo-ribaudo added the awaiting stage 2.7 Supports a "Stage 2" feature label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting stage 2.7 Supports a "Stage 2" feature needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants