Skip to content

fix: remove redundant bare side-effect imports in entry/facade chunks#8804

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks
Mar 21, 2026
Merged

fix: remove redundant bare side-effect imports in entry/facade chunks#8804
graphite-app[bot] merged 1 commit intomainfrom
03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks

Conversation

@h-a-n-a
Copy link
Copy Markdown
Member

@h-a-n-a h-a-n-a commented Mar 19, 2026

Summary

Remove redundant bare side-effect imports from entry/facade chunks. Previously, a bit-based pass added
bare imports for ALL reachable side-effectful chunks to entry points, even when those chunks were already
transitively loaded through binding imports.

Changes

  • Replace the broad bit-based chunk lookup with import-record-based checks that add bare imports only where the
    actual dependency exists (any chunk, not just entries)
  • Ensure facade entries import their entry module's chunk so it executes. (This was implicitly handled in bit-based reachability check)
  • Add .has_side_effectful_runtime_dep field if runtime has side-effect (e.g. runtime in dev/HMR mode)

Related issues

closes #8252

Copy link
Copy Markdown
Member Author

h-a-n-a commented Mar 19, 2026


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
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 9e3fd41
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69be820b5748070008454243
😎 Deploy Preview https://deploy-preview-8804--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@h-a-n-a h-a-n-a force-pushed the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch from 1ea9e97 to 6cc1dd5 Compare March 19, 2026 18:13
@h-a-n-a h-a-n-a force-pushed the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch from 6cc1dd5 to 133d2b7 Compare March 19, 2026 18:21
@h-a-n-a h-a-n-a marked this pull request as ready for review March 19, 2026 18:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 19, 2026

Benchmarks Rust

  • target: main(89f0938)
  • pr: 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks(084bccf)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     69.5±3.80ms        ? ?/sec    1.03     71.5±4.63ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.02     77.8±6.16ms        ? ?/sec    1.00     76.1±3.26ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00   156.2±12.25ms        ? ?/sec    1.02   159.6±13.68ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    174.3±9.13ms        ? ?/sec    1.04   180.4±10.93ms        ? ?/sec
bundle/bundle@threejs                                        1.03     64.3±3.99ms        ? ?/sec    1.00     62.5±2.71ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     74.5±3.36ms        ? ?/sec    1.01     74.8±2.86ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00   765.1±42.06ms        ? ?/sec    1.00   762.1±36.93ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00   847.7±37.59ms        ? ?/sec    1.01   854.3±37.35ms        ? ?/sec

@h-a-n-a h-a-n-a force-pushed the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch from 133d2b7 to 084bccf Compare March 19, 2026 19:11
@shulaoda shulaoda requested a review from IWANABETHATGUY March 19, 2026 19:31
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 19, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks (6c5e6e6) with main (68c7bf5)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@hyf0
Copy link
Copy Markdown
Member

hyf0 commented Mar 20, 2026

I just checked #8252, I think the original code is not even a bug.

@hyf0 hyf0 assigned hyf0 and unassigned h-a-n-a Mar 20, 2026
@hyf0 hyf0 requested a review from Copilot March 20, 2026 13:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines how rolldown injects cross-chunk bare imports for side-effect execution, aiming to avoid redundant imports in entry/facade chunks while still ensuring required side effects run (including special cases like dev/HMR runtime injection).

Changes:

  • Replace entry-bit reachability–based bare-import injection with checks derived from actual module dependency relationships (import-record/meta driven).
  • Ensure facade entry chunks import the chunk containing their real entry module so the entry code executes.
  • Track “injected” side-effect dependencies (e.g. dev/HMR runtime) via LinkingMetadata::injected_side_effect_deps and include them in cross-chunk linking.

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/rolldown/tests/fixtures/plugin/context/emit-chunk/_config.ts Updates inline snapshot for emitted chunk filename hash.
crates/rolldown/tests/rolldown/issues/8361_2/artifacts.snap Snapshot update reflecting reduced redundant bare imports.
crates/rolldown/tests/rolldown/issues/8252/_config.json Adds regression test configuration for issue #8252.
crates/rolldown/tests/rolldown/issues/8252/index.js Adds fixture entry for multi-entry case reproducing redundant imports.
crates/rolldown/tests/rolldown/issues/8252/sorter.js Adds fixture module for the repro graph.
crates/rolldown/tests/rolldown/issues/8252/sorting.js Adds fixture module for the repro graph.
crates/rolldown/tests/rolldown/issues/8252/v3.js Adds fixture dynamic import target for the repro graph.
crates/rolldown/tests/rolldown/issues/8252/resolve.js Adds fixture dependency that pulls in a package to create side-effectful chunking scenario.
crates/rolldown/tests/rolldown/issues/8252/node_modules/enhanced-resolve/package.json Adds minimal stub package metadata for fixture resolution.
crates/rolldown/tests/rolldown/issues/8252/node_modules/enhanced-resolve/lib/index.js Adds minimal CJS exports for the stub package.
crates/rolldown/tests/rolldown/issues/8252/artifacts.snap Adds snapshot asserting redundant bare imports are removed for #8252.
crates/rolldown/tests/esbuild/default/top_level_await_allowed_import_with_splitting/artifacts.snap Snapshot update reflecting adjusted bare-import placement.
crates/rolldown/src/types/linking_metadata.rs Introduces injected_side_effect_deps to represent deps needing bare imports without import records.
crates/rolldown/src/stages/link_stage/patch_module_dependencies.rs Populates injected_side_effect_deps for entry modules when runtime has side effects (dev/HMR).
crates/rolldown/src/stages/generate_stage/compute_cross_chunk_links.rs Reworks cross-chunk bare-import injection (incl. facade-entry import of the real entry chunk, and injected deps).

Copy link
Copy Markdown
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

@hyf0 hyf0 assigned h-a-n-a and unassigned hyf0 Mar 20, 2026
@hyf0
Copy link
Copy Markdown
Member

hyf0 commented Mar 20, 2026

@h-a-n-a One convention rule is that only PR's assignee gets to merge the PR.

@h-a-n-a h-a-n-a force-pushed the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch from 084bccf to 6c5e6e6 Compare March 21, 2026 10:49
Copy link
Copy Markdown
Member Author

h-a-n-a commented Mar 21, 2026

Merge activity

  • Mar 21, 11:32 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.
  • Mar 21, 11:32 AM UTC: h-a-n-a added this pull request to the Graphite merge queue.
  • Mar 21, 11:37 AM UTC: Merged by the Graphite merge queue.

…#8804)

## Summary

Remove redundant bare side-effect imports from entry/facade chunks. Previously, a bit-based pass added
bare imports for ALL reachable side-effectful chunks to entry points, even when those chunks were already
transitively loaded through binding imports.

## Changes

- Replace the broad bit-based chunk lookup with import-record-based checks that add bare imports only where the
actual dependency exists (any chunk, not just entries)
- Ensure facade entries import their entry module's chunk so it executes. (This was implicitly handled in bit-based reachability check)
- Add `injected_side_effect_deps` field for deps without import records (e.g. runtime in dev/HMR mode)

## Related issues

closes #8252
@graphite-app graphite-app bot force-pushed the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch from 6c5e6e6 to 9e3fd41 Compare March 21, 2026 11:33
@graphite-app graphite-app bot merged commit 9e3fd41 into main Mar 21, 2026
31 checks passed
@graphite-app graphite-app bot deleted the 03-20-fix_remove_redundant_bare_side-effect_imports_in_entry_facade_chunks branch March 21, 2026 11:37
@github-actions github-actions bot mentioned this pull request Mar 23, 2026
shulaoda added a commit that referenced this pull request Mar 23, 2026
## [1.0.0-rc.11] - 2026-03-23

### 🚀 Features

- magicString replace with regex (#8802) by @IWANABETHATGUY
- support `output.sourcemapExcludeSources` option (#8828) by @sapphi-red
- support `getIndentString` in MagicString (#8775) by @IWANABETHATGUY
- MagicString ignoreList support (#8773) by @IWANABETHATGUY

### 🐛 Bug Fixes

- types: remove `pluginName` from `MinimalPluginContext` (#8864) by @sapphi-red
- do not report eval?.() as direct eval (#8860) by @IWANABETHATGUY
- handle negative indices, overlapping ranges, and moved content in MagicString remove (#8829) by @IWANABETHATGUY
- enable arbitrary_precision for serde_json to fix JSON float parsing (#8848) by @elderapo
- resolve TypeScript lint errors (#8841) by @Boshen
- avoid panic on multi-byte UTF-8 chars in hash placeholder iterator (#8790) by @shulaoda
- ci: skip failing vite build watch raw query test (#8840) by @Boshen
- ci: use step-level env override to unset VITE_PLUS_CLI_BIN in vite tests (#8838) by @Boshen
- ci: move vite tests into CI workflow by @Boshen
- ci: unset all VITE_PLUS_* env vars in vite-tests workflow (#8837) by @Boshen
- test: skip watch CLI tests on Windows (#8830) by @Boshen
- ci: unset VITE_PLUS_CLI_BIN in vite-tests workflow (#8832) by @Boshen
- remove redundant bare side-effect imports in entry/facade chunks (#8804) by @h-a-n-a
- magicString prepend issues (#8797) by @IWANABETHATGUY
- ci: use `vpx` instead of `vp exec` for `pkg-pr-new` (#8827) by @Boshen
- set `order` for callable plugins (#8815) by @sapphi-red
- handle reversed slice ranges with moved content (#8750) by @IWANABETHATGUY
- update emnapi to latest to avoid version mismatch (#8781) by @sapphi-red
- external.md on Windows OS (#8780) by @bddjr
- align MagicString length/isEmpty with reference magic-string (#8776) by @IWANABETHATGUY

### 🚜 Refactor

- extract canonical_ref_resolving_namespace helper (#8836) by @Boshen

### 📚 Documentation

- improve external examples for cross-platform correctness (#8786) by @hyf0-agent
- update reference to transform function in plugin API documentation (#8778) by @zOadT

### ⚡ Performance

- reduce timing of `dervie_entries_aware_chunk_name` (#8847) by @AliceLanniste
- bench: remove redundant sourcemap benchmark cases (#8825) by @Boshen
- reduce intermediate allocations in `collapse_sourcemaps` (#8821) by @Boshen
- enable parallel AST cloning on macOS (#8814) by @Boshen

### 🧪 Testing

- watch: use polling watcher and retry for watch error test (#8772) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- justfile: skip setup-vite-plus if vp is already installed (#8862) by @Boshen
- add expectWarning option to test config (#8861) by @IWANABETHATGUY
- justfile: support windows for `just setup` (#8846) by @AliceLanniste
- deps: update rust crates (#8852) by @renovate[bot]
- deps: update endbug/version-check action to v3 (#8855) by @renovate[bot]
- deps: update github-actions (#8853) by @renovate[bot]
- deps: update dependency vitepress to v2.0.0-alpha.17 (#8854) by @renovate[bot]
- deps: update npm packages (#8851) by @renovate[bot]
- bench: use mimalloc as global allocator in bench crate (#8844) by @IWANABETHATGUY
- reuse native build artifact in node-validation job (#8826) by @Boshen
- speed up CodSpeed benchmark build by disabling LTO (#8824) by @Boshen
- remove redundant critcmp benchmark job (#8823) by @Boshen
- deps: update rust crate oxc_sourcemap to v6.1.0 (#8785) by @renovate[bot]
- node: migrate oxlint and oxfmt to Vite+ (#8813) by @Boshen
- revert namespace runners for release build jobs (#8820) by @Boshen
- migrate runners to namespace (#8819) by @Boshen
- test: relax test utils path assertion to support git worktrees (#8816) by @younggglcy
- rename `examples/lazy` to `examples/lazy-compilation` (#8789) by @shulaoda
- improve "needs reproduction" wording by @Boshen
- deps: update dependency oxlint-tsgolint to v0.17.1 (#8807) by @renovate[bot]
- enable 7 previously-skipped MagicString tests (#8771) by @IWANABETHATGUY
- upgrade oxc to 0.121.0 (#8784) by @shulaoda
- increase Windows dev drive size from 12GB to 20GB (#8779) by @Copilot

### ❤️ New Contributors

* @elderapo made their first contribution in [#8848](#8848)
* @younggglcy made their first contribution in [#8816](#8816)
* @bddjr made their first contribution in [#8780](#8780)
* @zOadT made their first contribution in [#8778](#8778)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
This was referenced Mar 23, 2026
shulaoda added a commit that referenced this pull request Mar 23, 2026
## [1.0.0-rc.11] - 2026-03-23

### 🚀 Features

- magicString replace with regex (#8802) by @IWANABETHATGUY
- support `output.sourcemapExcludeSources` option (#8828) by @sapphi-red
- support `getIndentString` in MagicString (#8775) by @IWANABETHATGUY
- MagicString ignoreList support (#8773) by @IWANABETHATGUY

### 🐛 Bug Fixes

- forward test filters through vp run (#8870) by @younggglcy
- types: remove `pluginName` from `MinimalPluginContext` (#8864) by @sapphi-red
- do not report eval?.() as direct eval (#8860) by @IWANABETHATGUY
- handle negative indices, overlapping ranges, and moved content in MagicString remove (#8829) by @IWANABETHATGUY
- enable arbitrary_precision for serde_json to fix JSON float parsing (#8848) by @elderapo
- resolve TypeScript lint errors (#8841) by @Boshen
- avoid panic on multi-byte UTF-8 chars in hash placeholder iterator (#8790) by @shulaoda
- ci: skip failing vite build watch raw query test (#8840) by @Boshen
- ci: use step-level env override to unset VITE_PLUS_CLI_BIN in vite tests (#8838) by @Boshen
- ci: move vite tests into CI workflow by @Boshen
- ci: unset all VITE_PLUS_* env vars in vite-tests workflow (#8837) by @Boshen
- test: skip watch CLI tests on Windows (#8830) by @Boshen
- ci: unset VITE_PLUS_CLI_BIN in vite-tests workflow (#8832) by @Boshen
- remove redundant bare side-effect imports in entry/facade chunks (#8804) by @h-a-n-a
- magicString prepend issues (#8797) by @IWANABETHATGUY
- ci: use `vpx` instead of `vp exec` for `pkg-pr-new` (#8827) by @Boshen
- set `order` for callable plugins (#8815) by @sapphi-red
- handle reversed slice ranges with moved content (#8750) by @IWANABETHATGUY
- update emnapi to latest to avoid version mismatch (#8781) by @sapphi-red
- external.md on Windows OS (#8780) by @bddjr
- align MagicString length/isEmpty with reference magic-string (#8776) by @IWANABETHATGUY

### 🚜 Refactor

- extract canonical_ref_resolving_namespace helper (#8836) by @Boshen

### 📚 Documentation

- improve external examples for cross-platform correctness (#8786) by @hyf0-agent
- update reference to transform function in plugin API documentation (#8778) by @zOadT

### ⚡ Performance

- reduce timing of `dervie_entries_aware_chunk_name` (#8847) by @AliceLanniste
- bench: remove redundant sourcemap benchmark cases (#8825) by @Boshen
- reduce intermediate allocations in `collapse_sourcemaps` (#8821) by @Boshen
- enable parallel AST cloning on macOS (#8814) by @Boshen

### 🧪 Testing

- watch: use polling watcher and retry for watch error test (#8772) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- deps: update dependency @oxc-project/types to v0.122.0 (#8873) by @renovate[bot]
- publish-to-npm: use correct vp pm publish (#8871) by @shulaoda
- justfile: skip setup-vite-plus if vp is already installed (#8862) by @Boshen
- add expectWarning option to test config (#8861) by @IWANABETHATGUY
- justfile: support windows for `just setup` (#8846) by @AliceLanniste
- deps: update rust crates (#8852) by @renovate[bot]
- deps: update endbug/version-check action to v3 (#8855) by @renovate[bot]
- deps: update github-actions (#8853) by @renovate[bot]
- deps: update dependency vitepress to v2.0.0-alpha.17 (#8854) by @renovate[bot]
- deps: update npm packages (#8851) by @renovate[bot]
- bench: use mimalloc as global allocator in bench crate (#8844) by @IWANABETHATGUY
- reuse native build artifact in node-validation job (#8826) by @Boshen
- speed up CodSpeed benchmark build by disabling LTO (#8824) by @Boshen
- remove redundant critcmp benchmark job (#8823) by @Boshen
- deps: update rust crate oxc_sourcemap to v6.1.0 (#8785) by @renovate[bot]
- node: migrate oxlint and oxfmt to Vite+ (#8813) by @Boshen
- revert namespace runners for release build jobs (#8820) by @Boshen
- migrate runners to namespace (#8819) by @Boshen
- test: relax test utils path assertion to support git worktrees (#8816) by @younggglcy
- rename `examples/lazy` to `examples/lazy-compilation` (#8789) by @shulaoda
- improve "needs reproduction" wording by @Boshen
- deps: update dependency oxlint-tsgolint to v0.17.1 (#8807) by @renovate[bot]
- enable 7 previously-skipped MagicString tests (#8771) by @IWANABETHATGUY
- upgrade oxc to 0.121.0 (#8784) by @shulaoda
- increase Windows dev drive size from 12GB to 20GB (#8779) by @Copilot

### ❤️ New Contributors

* @younggglcy made their first contribution in [#8870](#8870)
* @elderapo made their first contribution in [#8848](#8848)
* @bddjr made their first contribution in [#8780](#8780)
* @zOadT made their first contribution in [#8778](#8778)

---------

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
viclafouch added a commit to viclafouch/petit-meme that referenced this pull request Mar 26, 2026
- vite 7.3.1→8.0.3 (Rolldown rc.12, __exportAll SSR bug fixed)
- @vitejs/plugin-react 5.1.4→6.0.1 (Babel removed, Oxc transforms)
- vite-node 5.3.0→6.0.0
- Remove vite-tsconfig-paths, use native resolve.tsconfigPaths

The __exportAll hoisting bug (rolldown/rolldown#8804) that broke the
March 21 attempt is fixed in Rolldown rc.11+ (shipped in Vite 8.0.2+).

Co-Authored-By: Claude Opus 4.6 (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]: redundant side-effect imports in facade entry chunks

4 participants