Skip to content

fix(finalizer): skip wrapped ESM init fallback for static cross-chunk barrels#9520

Draft
IWANABETHATGUY wants to merge 4 commits into
mainfrom
05-22-fix_9502
Draft

fix(finalizer): skip wrapped ESM init fallback for static cross-chunk barrels#9520
IWANABETHATGUY wants to merge 4 commits into
mainfrom
05-22-fix_9502

Conversation

@IWANABETHATGUY

@IWANABETHATGUY IWANABETHATGUY commented May 22, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #9502.

When a non-wrapped barrel module is already executed through the current chunk's static dependency chain, the finalizer should not emit an extra fallback init_*() call for wrapped ESM re-export owners. That late synthetic call is not visible to cross-chunk import computation, so it can produce unbound identifiers such as init_shared() in the importer chunk.

This change extends the existing same-chunk guard to also cover statically imported chunks, while preserving the fallback for barrels that do not execute before the importer.

Changes

Tests

  • just dt crates\rolldown\tests\rolldown\issues\9502\_config.json
  • just dt crates\rolldown\tests\rolldown\issues\9502_named_import\_config.json
  • just dt crates\rolldown\tests\rolldown\issues\9502_side_effect_import\_config.json
  • just dt crates\rolldown\tests\rolldown\issues\9502_deep_chain\_config.json
  • just dt crates\rolldown\tests\rolldown\issues\8950\_config.json
  • just lint-rust

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@netlify

netlify Bot commented May 22, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 7c6c73f
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a2a2496684dfd00091bcd1b

@IWANABETHATGUY IWANABETHATGUY changed the title fix: 9502 fix(finalizer): skip wrapped ESM init fallback for static cross-chunk barrels May 22, 2026
IWANABETHATGUY and others added 2 commits June 3, 2026 10:28
Rely on the runtime entry import to surface a missing init_* import (it
throws ReferenceError on broken output) for the three eager-path fixtures;
keep the structural init_* scan only in 9502_deep_chain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep only the `9502` namespace-import fixture and drop the three
variants. Verified by reverting the fix against each:

- `9502` (namespace import): crashes with `ReferenceError: init_shared
  is not defined` -- the exact issue repro.
- `9502_named_import`: passes without the fix; the orphan `init_shared`
  is still correctly imported, so it only differed cosmetically.
- `9502_side_effect_import`: output byte-identical with/without the fix.
- `9502_deep_chain`: catches the bug, but the fix decision is made
  independently per import-record, so multi-hop adds no coverage the
  single-hop `9502` does not already guard.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Dep optimizer: missing init_shared_esm_bundler import in @vue/test-utils chunk when @vue/compiler-dom is split as a CJS-interop sub-chunk

1 participant