test: add regression test for #10099 (lazyBarrel drops default-import binding but keeps its property reads)#10109
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
hyf0
approved these changes
Jul 3, 2026
shulaoda
approved these changes
Jul 3, 2026
Member
Author
Merge activity
|
… binding but keeps its property reads) (#10109) ## What Adds a Rust integration-test fixture at `crates/rolldown/tests/rolldown/issues/10099/` closes #10099. ## Why #10099: importing only `dayjs` from `element-plus` emitted a bundle that threw `ReferenceError: defaults_default is not defined`. The `sideEffects:false` barrel (`index.mjs`) re-exports an **external** module's default (`dayjs`) as a passthrough while reading `defaults_default.install`/`.version` at the top level. Importing only that passthrough force-includes the barrel; under `experimental.lazyBarrel` the tree-shaker dropped the `defaults_default` import **and** its definition but kept the property reads → dangling reference. Fixed by #10080 (gate `sideEffects:false` modules' side effects on body demand). This PR adds the regression test for the specific element-plus shape, which none of #10080's fixtures cover: here the inclusion driver is an **external-default passthrough** (the sibling fixtures use local passthroughs or dynamic-import wrapping). ## The fixture - `_config.json`: `external:["extdep"]`, `experimental.lazyBarrel:true`, `treeshake.moduleSideEffects:false` - barrel `index.js` default-imports `defaults.js`, reads `.install`/`.version`, and re-exports the external default as `extdep` - entry `main.js` imports only `{ extdep }` and asserts it resolves - `node_modules/extdep/` stub so the external passthrough resolves at runtime `experimental.lazyBarrel: true` is load-bearing: the bug is lazyBarrel-gated and lazyBarrel is default-off since #10071, so without it the test would pass on both the base and the fix. ## Verification - **Green** on current `main` (fix present): the harness executes the compiled entry (`expectExecuted` default) and the snapshot is clean — no `defaults_default`. - **Red** on the pre-fix base: the exact fixture source + config through published `rolldown@1.1.3` throws `ReferenceError: defaults_default is not defined`. Test-only; no source changes.
ea42151 to
d68442c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Rust integration-test fixture at
crates/rolldown/tests/rolldown/issues/10099/closes #10099.Why
#10099: importing only
dayjsfromelement-plusemitted a bundle that threwReferenceError: defaults_default is not defined. ThesideEffects:falsebarrel (index.mjs) re-exports an external module's default (dayjs) as a passthrough while readingdefaults_default.install/.versionat the top level. Importing only that passthrough force-includes the barrel; underexperimental.lazyBarrelthe tree-shaker dropped thedefaults_defaultimport and its definition but kept the property reads → dangling reference.Fixed by #10080 (gate
sideEffects:falsemodules' side effects on body demand). This PR adds the regression test for the specific element-plus shape, which none of #10080's fixtures cover: here the inclusion driver is an external-default passthrough (the sibling fixtures use local passthroughs or dynamic-import wrapping).The fixture
_config.json:external:["extdep"],experimental.lazyBarrel:true,treeshake.moduleSideEffects:falseindex.jsdefault-importsdefaults.js, reads.install/.version, and re-exports the external default asextdepmain.jsimports only{ extdep }and asserts it resolvesnode_modules/extdep/stub so the external passthrough resolves at runtimeexperimental.lazyBarrel: trueis load-bearing: the bug is lazyBarrel-gated and lazyBarrel is default-off since #10071, so without it the test would pass on both the base and the fix.Verification
main(fix present): the harness executes the compiled entry (expectExecuteddefault) and the snapshot is clean — nodefaults_default.rolldown@1.1.3throwsReferenceError: defaults_default is not defined.Test-only; no source changes.