Skip to content

Comments

fix: support dynamic imports with shared dependencies#7261

Merged
graphite-app[bot] merged 1 commit intomainfrom
11-29-fix_4904-2
Dec 1, 2025
Merged

fix: support dynamic imports with shared dependencies#7261
graphite-app[bot] merged 1 commit intomainfrom
11-29-fix_4904-2

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Nov 29, 2025

related to #4904

Copy link
Member Author

IWANABETHATGUY commented Nov 29, 2025


How to use the Graphite Merge Queue

Add the label graphite: merge 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.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 29, 2025

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.04     70.9±3.23ms        ? ?/sec    1.00     68.0±3.12ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.05     80.4±4.48ms        ? ?/sec    1.00     76.7±4.86ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    112.3±2.41ms        ? ?/sec    1.00    111.8±2.53ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.01    126.7±2.45ms        ? ?/sec    1.00    125.2±2.28ms        ? ?/sec
bundle/bundle@threejs                                        1.00     41.7±2.82ms        ? ?/sec    1.02     42.4±3.12ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     44.8±1.06ms        ? ?/sec    1.03     45.9±1.36ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    420.0±9.06ms        ? ?/sec    1.01    425.1±8.49ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    478.3±8.54ms        ? ?/sec    1.00   474.5±10.96ms        ? ?/sec
scan/scan@rome_ts                                            1.03     90.3±2.65ms        ? ?/sec    1.00     87.3±2.55ms        ? ?/sec
scan/scan@threejs                                            1.03     30.0±0.91ms        ? ?/sec    1.00     29.2±0.98ms        ? ?/sec
scan/scan@threejs10x                                         1.02    310.1±4.82ms        ? ?/sec    1.00    302.6±5.09ms        ? ?/sec

@IWANABETHATGUY IWANABETHATGUY changed the base branch from 11-20-feat_4904 to graphite-base/7261 November 30, 2025 08:05
@IWANABETHATGUY IWANABETHATGUY changed the base branch from graphite-base/7261 to 11-20-feat_4904 November 30, 2025 08:19
@IWANABETHATGUY IWANABETHATGUY changed the title fix: 4904-2 fix: support dynamic imports with shared dependencies Nov 30, 2025
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review November 30, 2025 08:39
Copy link
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.

I felt like the code_splitting​ stage now is doing too much of work.

The logic of splitting modules into chunks and optimizing them based on some assumptions are hard -coded and don't have a clear boundary.

The ideal abstraction layer would be:

- Code splitting generate chunks by following simple and intuitive rules described in https://rolldown.rs/in-depth/code-splitting
- Have a Chunk Optimizer​ abstraction to optimize optimizable patterns.

This will make us easy to locate the issue code when the output is not expected

This allows us to opt-in the chunk optimizer​ behavior, which also makes debugging easier.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

@rolldown/browser

npm i https://pkg.pr.new/@rolldown/browser@7261

@rolldown/debug

npm i https://pkg.pr.new/@rolldown/debug@7261

@rolldown/pluginutils

npm i https://pkg.pr.new/@rolldown/pluginutils@7261

rolldown

npm i https://pkg.pr.new/rolldown@7261

@rolldown/binding-android-arm64

npm i https://pkg.pr.new/@rolldown/binding-android-arm64@7261

@rolldown/binding-darwin-arm64

npm i https://pkg.pr.new/@rolldown/binding-darwin-arm64@7261

@rolldown/binding-darwin-x64

npm i https://pkg.pr.new/@rolldown/binding-darwin-x64@7261

@rolldown/binding-freebsd-x64

npm i https://pkg.pr.new/@rolldown/binding-freebsd-x64@7261

@rolldown/binding-linux-arm-gnueabihf

npm i https://pkg.pr.new/@rolldown/binding-linux-arm-gnueabihf@7261

@rolldown/binding-linux-arm64-gnu

npm i https://pkg.pr.new/@rolldown/binding-linux-arm64-gnu@7261

@rolldown/binding-linux-arm64-musl

npm i https://pkg.pr.new/@rolldown/binding-linux-arm64-musl@7261

@rolldown/binding-linux-x64-gnu

npm i https://pkg.pr.new/@rolldown/binding-linux-x64-gnu@7261

@rolldown/binding-linux-x64-musl

npm i https://pkg.pr.new/@rolldown/binding-linux-x64-musl@7261

@rolldown/binding-openharmony-arm64

npm i https://pkg.pr.new/@rolldown/binding-openharmony-arm64@7261

@rolldown/binding-wasm32-wasi

npm i https://pkg.pr.new/@rolldown/binding-wasm32-wasi@7261

@rolldown/binding-win32-arm64-msvc

npm i https://pkg.pr.new/@rolldown/binding-win32-arm64-msvc@7261

@rolldown/binding-win32-x64-msvc

npm i https://pkg.pr.new/@rolldown/binding-win32-x64-msvc@7261

commit: 2e49540

@sapphi-red
Copy link
Member

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 1, 2025

Merge activity

@graphite-app graphite-app bot changed the base branch from 11-20-feat_4904 to graphite-base/7261 December 1, 2025 01:59
@IWANABETHATGUY
Copy link
Member Author

It seems some cases are not fixed by this PR:

let allow_extension_optimize = (!matches!(self.options.preserve_entry_signatures, PreserveEntrySignatures::Strict)
|| !self.link_output.overrode_preserve_entry_signature_map.is_empty())
// partial workaround of https://github.com/rolldown/rolldown/issues/5026#issuecomment-2990146735
// TODO: maybe we could bailout peer chunk?
&& !self.link_output.metas.iter().any(|meta| meta.is_tla_or_contains_tla_dependency);
, the optimization is still disabled when preserveEntrySignature: strict, see https://repl.rolldown.rs/#eNptkEFPhDAQhf/KpBcg2ZToQRMMxotnE71yIdBiTZmSdljdEP67UwsY456aeX3v9ZsuQotqEd5Z27tPlJ1DbQZJIaooqms3J9HxhRkn5wnoMilY4HWzvUxkHAZYQXs3QrbHswa5IBCkmupfoIalQYCyhMmroPxZPSP5y5sZsKWZpQqyQN50xFVrgw2qrx+AXul2tntxg2I9CRWj8uNY4pj/oC+gnTtIZckTe7KHhOqsktYNOasFSw2mVP5rLCS9K8zz0fUF1I+R4EixJmMyRvlVJSrys2K0lN3BtilhbQulf4poNWR8MJDfS3Rrg1q55sz+wdDT/e3djVi/ATRQmzM=

@IWANABETHATGUY IWANABETHATGUY changed the base branch from graphite-base/7261 to 11-20-feat_4904 December 1, 2025 02:11
@sapphi-red
Copy link
Member

@IWANABETHATGUY Do you mean that it will be worked on in a separate PR?

Copy link
Member Author

Yeah, I change the description to related to instaed of closed

Base automatically changed from 11-20-feat_4904 to main December 1, 2025 03:15
@netlify
Copy link

netlify bot commented Dec 1, 2025

Deploy Preview for rolldown-rs failed.

Name Link
🔨 Latest commit 911c7ad
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/692d24ec2acb7a5bf957e45a

Copilot AI review requested due to automatic review settings December 1, 2025 03:44
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@graphite-app graphite-app bot merged commit 911c7ad into main Dec 1, 2025
24 of 28 checks passed
@graphite-app graphite-app bot deleted the 11-29-fix_4904-2 branch December 1, 2025 04:03
This was referenced Dec 3, 2025
shulaoda added a commit that referenced this pull request Dec 3, 2025
## [1.0.0-beta.53] - 2025-12-03

💥 Breaking Changes
- Drop `i686-pc-windows-msvc` target support

🚀 Chunk Merging Optimization
- Rolldown now automatically merges shared chunks when entries import each other (when `preserveEntrySignature` is not `strict`)
```shell
Before:
entry.js   → imports → shared.js (common chunk)
entry2.js  → imports → shared.js
Output: 3 chunks (entry.js, entry2.js, shared.js)

After:
entry.js   → contains shared code
entry2.js  → imports → entry.js
Output: 2 chunks (entry.js, entry2.js)
```

### 💥 BREAKING CHANGES

- drop `i686-pc-windows-msvc` target support (#7230) by @sapphi-red

### 🚀 Features

- rolldown_plugin_vite_manifest: pass normalized options to `isLegacy` callback (#7321) by @shulaoda
- plugin/vite-resolve: add `disableCache` option (#6763) by @sapphi-red
- rolldown: export `createTokioRuntime` for tsdown (#7264) by @shulaoda
- rolldown_plugin_vite_html: sync `moduleSideEffects` for already loaded modules (#7254) by @shulaoda
- rolldown_plugin_vite_html: load module scripts with side effects to prevent tree-shaking (#7244) by @shulaoda
- rolldown_plugin_vite_css_post: implement `cssScopeTo` for scoped CSS tree-shaking (#7240) by @shulaoda

### 🐛 Bug Fixes

- export default class decl __name runtime insertion (#7316) by @IWANABETHATGUY
- chunk side effects calculation (#7273) by @IWANABETHATGUY
- node: `output.generateCode.preset: 'es2015'` should set `output.generateCode.symbols: true` by default (#7314) by @sapphi-red
- skip name helper for classes with static name property (#7312) by @IWANABETHATGUY
- preserve chunk imports relationship after chunk merging (#7303) by @shulaoda
- dev: make `register_modules` async (#7289) by @hyf0
- preserve computed property in object destructuring (#7288) by @IWANABETHATGUY
- support dynamic imports with shared dependencies (#7261) by @IWANABETHATGUY
- call `defer_sync_scan_data` in non-incremental build mode (#7255) by @shulaoda
- optimize chunk merging for shared entry points (#7194) by @IWANABETHATGUY
- add indentation for UMD format output (#7263) by @IWANABETHATGUY
- rolldown_plugin_vite_css_post: pass options to `isLegacy` callback for proper legacy detection (#7260) by @shulaoda
- rolldown_plugin_vite_css_post: also detect `?inline=true` query for inlined CSS (#7245) by @shulaoda
- rolldown_plugin_vite_css_post: distinguish empty CSS from no CSS (#7241) by @shulaoda
- add Windows support for t-run command (#7242) by @IWANABETHATGUY
- cjs: prevent duplicate require declarations for external modules with preserveModules (#7234) by @logaretm
- rolldown_plugin_vite_resolve: resolve from root for virtual modules (#7236) by @sapphi-red
- include entry level external modules in chunk exports (#7218) by @IWANABETHATGUY

### 🚜 Refactor

- dev: make `removeClient` async (#7313) by @hyf0
- move chunk merging code out of code_splitting.rs (#7285) by @IWANABETHATGUY
- extract common function util for chunk merging (#7271) by @IWANABETHATGUY
- use iterative method to merge chunks (#7256) by @IWANABETHATGUY
- use concat_string! instead of string replace for generating chunk level exports (#7247) by @IWANABETHATGUY

### 📚 Documentation

- add warning to experimental.resolveNewUrlToAsset about JS/TS files (#7300) by @Copilot
- add sequential hook execution difference in plugin-api.md (#7308) by @Copilot
- add migration example from onwarn to onLog (#7299) by @Copilot
- add migration example for manualChunks to advancedChunks (#7298) by @Copilot
- deps: bump vitepress to fix build (#7307) by @sapphi-red
- examples & text for experimental.resolveNewUrlToAsset (#7259) by @TheAlexLichter

### ⚡ Performance

- rolldown_plugin_vite_css_post: lazily load `cssScopeTo` from JS module options (#7253) by @shulaoda
- rolldown_plugin_vite_css_post: avoid unnecessary string clones in `resolve_asset_urls_in_css` (#7250) by @shulaoda

### 🧪 Testing

- generate relative path like name in advanced chunks (#7267) by @IWANABETHATGUY
- add test case for preserveEntrySignatures with re-exports (#7279) by @IWANABETHATGUY
- add test262 integration tests (#7196) by @sapphi-red

### ⚙️ Miscellaneous Tasks

- deps: update dependency rolldown-plugin-dts to v0.18.1 (#7304) by @renovate[bot]
- enable tracing feature for napi (#7322) by @sapphi-red
- deps: update napi (#7320) by @renovate[bot]
- deps: update oxc (#7318) by @renovate[bot]
- deps: update napi (#7317) by @renovate[bot]
- deps: update oxc to v0.100.0 (#7301) by @renovate[bot]
- deps: downgrade pnpm to 10.23.0 to fix Netlify build (#7306) by @shulaoda
- add `trustPolicyExclude` for chokidar and semver (#7302) by @sapphi-red
- update pnpm lockfile (#7291) by @IWANABETHATGUY
- deps: update npm packages (#7272) by @renovate[bot]
- deps: update rust crates (#7270) by @renovate[bot]
- deps: update oxc (#7262) by @renovate[bot]
- deps: update github-actions (#7269) by @renovate[bot]
- deps: update dependency dprint-typescript to v0.95.13 (#7268) by @renovate[bot]
- deps: update `html5gum` to 0.8.1 (#7265) by @shulaoda
- rolldown: remove unused `getModuleOptions` from `PluginContext` (#7266) by @shulaoda
- remove unnecessary justfile ignore (#7243) by @IWANABETHATGUY
- deps: update oxc apps (#7238) by @renovate[bot]
- add `nul` to workaround https://github.com/anthropics/claude-c… (#7237) by @IWANABETHATGUY
- deps: update dependency valibot to v1.2.0 [security] (#7231) by @renovate[bot]
- deps: update crate-ci/typos action to v1.40.0 (#7232) by @renovate[bot]

### ❤️ New Contributors

* @logaretm made their first contribution in [#7234](#7234)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants