Skip to content

test: add regression test for #10099 (lazyBarrel drops default-import binding but keeps its property reads)#10109

Merged
graphite-app[bot] merged 1 commit into
mainfrom
test/issue-10099-lazybarrel-regression
Jul 3, 2026
Merged

test: add regression test for #10099 (lazyBarrel drops default-import binding but keeps its property reads)#10109
graphite-app[bot] merged 1 commit into
mainfrom
test/issue-10099-lazybarrel-regression

Conversation

@IWANABETHATGUY

@IWANABETHATGUY IWANABETHATGUY commented Jul 3, 2026

Copy link
Copy Markdown
Member

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.

@netlify

netlify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

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

@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review July 3, 2026 07:38

IWANABETHATGUY commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jul 3, 8:06 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 3, 8:06 AM UTC: IWANABETHATGUY added this pull request to the Graphite merge queue.
  • Jul 3, 8:11 AM UTC: Merged by the Graphite merge queue.

… 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.
@graphite-app graphite-app Bot force-pushed the test/issue-10099-lazybarrel-regression branch from ea42151 to d68442c Compare July 3, 2026 08:07
@graphite-app graphite-app Bot merged commit d68442c into main Jul 3, 2026
33 checks passed
@graphite-app graphite-app Bot deleted the test/issue-10099-lazybarrel-regression branch July 3, 2026 08:11
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.

Tree-shaking removes default import binding but keeps property accesses, causing ReferenceError

3 participants