Skip to content

fix(dev/lazy): fix exports of lazy requests in lazy chunks#9249

Merged
graphite-app[bot] merged 1 commit into
mainfrom
04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks
May 12, 2026
Merged

fix(dev/lazy): fix exports of lazy requests in lazy chunks#9249
graphite-app[bot] merged 1 commit into
mainfrom
04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks

Conversation

@h-a-n-a

@h-a-n-a h-a-n-a commented Apr 28, 2026

Copy link
Copy Markdown
Member

Summary

This PR fixes a case where dynamic imported chunks in lazy chunks are not able to fetch the correct exports.

Before:

import(`/@vite/lazy?id=…&clientId=…`)

After:

import(`/@vite/lazy?id=…&clientId=…`)
    .then(() => __rolldown_runtime__.loadExports("<stable_proxy_id>"))

When a lazy chunk's body contains import('./another-lazy.js'), the HMR partial
bundle returned the raw chunk namespace (raw lazy chunk) instead of the registered proxy exports,
so inner.foo came back undefined.

In this PR, we intentionally skip loading the raw lazy chunk, instead,
we use __rolldown_runtime__.loadExports(...) to load real module exports.

Test plan

  • pnpm test:browser — all 7 tests pass with the fix in place
  • New playground: packages/test-dev-server/tests/playground/lazy-nested-dynamic-import/
  • Reverted the fix locally → pnpm test:browser -t 'lazy-nested-dynamic-import' fails with
    inner.foo = UNDEFINED / inner.bar = UNDEFINED
  • Restored the fix → test passes on first try (~135 ms, no retry)
  • pnpm run lint-knip clean for the new playground

h-a-n-a commented Apr 28, 2026

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.

@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from e7bd6bc to 739a535 Compare April 29, 2026 08:51
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 0b49d58 to 35914c4 Compare April 29, 2026 08:51
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 35914c4 to 852f962 Compare April 29, 2026 08:55
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch 3 times, most recently from d4233fa to 98e5569 Compare April 29, 2026 15:53
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 852f962 to 7e39c60 Compare April 29, 2026 15:53
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 3c07aa1 to 663a25f Compare April 29, 2026 16:09
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 7e39c60 to 817d34b Compare April 29, 2026 16:09
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 663a25f to 2a1a1bd Compare April 29, 2026 16:18
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 817d34b to 11bdba7 Compare April 29, 2026 16:18
@graphite-app graphite-app Bot force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch 2 times, most recently from 731e03d to 872b05f Compare April 30, 2026 08:38
@graphite-app graphite-app Bot force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 2a1a1bd to d32c3bc Compare April 30, 2026 08:38
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from 872b05f to db8a48f Compare May 6, 2026 06:55
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from d32c3bc to e8e212e Compare May 6, 2026 06:55
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from e8e212e to 30cde67 Compare May 6, 2026 06:56
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from db8a48f to 565a66a Compare May 6, 2026 06:56
@graphite-app graphite-app Bot force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch 2 times, most recently from 65d51b3 to ec35a9a Compare May 6, 2026 07:28
@graphite-app graphite-app Bot force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 30cde67 to 4ce2b61 Compare May 6, 2026 07:28
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch 2 times, most recently from 5ebe23c to f544df9 Compare May 11, 2026 06:19
@h-a-n-a h-a-n-a force-pushed the 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names branch from b43e44f to a3ce294 Compare May 11, 2026 06:19
@h-a-n-a h-a-n-a changed the base branch from 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names to graphite-base/9249 May 11, 2026 06:21
@h-a-n-a h-a-n-a force-pushed the graphite-base/9249 branch from a3ce294 to d0da050 Compare May 11, 2026 07:53
@h-a-n-a h-a-n-a force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 639b2d7 to e20e568 Compare May 11, 2026 07:53
@h-a-n-a h-a-n-a changed the base branch from graphite-base/9249 to 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names May 11, 2026 07:53
@h-a-n-a h-a-n-a marked this pull request as ready for review May 11, 2026 08:00
@codspeed-hq

codspeed-hq Bot commented May 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks (f2ff2a6) with main (8ada1f7)2

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.

  2. No successful run was found on main (07da851) during the generation of this report, so 8ada1f7 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app graphite-app Bot changed the base branch from 04-16-fix_rolldown_plugin_lazy_compilation_use_loadexports_for_fetched_proxy_to_preserve_original_export_names to graphite-base/9249 May 11, 2026 09:54
@graphite-app graphite-app Bot force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from e20e568 to 6bb09e0 Compare May 11, 2026 09:59
@graphite-app graphite-app Bot force-pushed the graphite-base/9249 branch from d0da050 to 07da851 Compare May 11, 2026 09:59
@graphite-app graphite-app Bot changed the base branch from graphite-base/9249 to main May 11, 2026 10:00
@graphite-app graphite-app Bot force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from 6bb09e0 to f2ff2a6 Compare May 11, 2026 10:00
@netlify

netlify Bot commented May 11, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs failed.

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

h-a-n-a commented May 12, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • May 12, 2:04 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.
  • May 12, 2:04 AM UTC: h-a-n-a added this pull request to the Graphite merge queue.
  • May 12, 2:09 AM UTC: Merged by the Graphite merge queue.

## Summary

This PR fixes a case where dynamic imported chunks in lazy chunks are not able to fetch the correct exports.

Before:

```js
import(`/@vite/lazy?id=…&clientId=…`)
```

After:

```js
import(`/@vite/lazy?id=…&clientId=…`)
    .then(() => __rolldown_runtime__.loadExports("<stable_proxy_id>"))
```

When a lazy chunk's body contains `import('./another-lazy.js')`, the HMR partial
bundle returned the raw chunk namespace (raw lazy chunk) instead of the registered proxy exports,
so `inner.foo` came back `undefined`.

In this PR, we intentionally skip loading the raw lazy chunk, instead,
we use `__rolldown_runtime__.loadExports(...)` to load real module exports.

## Test plan

- [x] `pnpm test:browser` — all 7 tests pass with the fix in place
- [x] New playground: `packages/test-dev-server/tests/playground/lazy-nested-dynamic-import/`
- [x] Reverted the fix locally → `pnpm test:browser -t 'lazy-nested-dynamic-import'` fails with
`inner.foo = UNDEFINED` / `inner.bar = UNDEFINED`
- [x] Restored the fix → test passes on first try (~135 ms, no retry)
- [x] `pnpm run lint-knip` clean for the new playground
@graphite-app graphite-app Bot force-pushed the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch from f2ff2a6 to 4ab16d1 Compare May 12, 2026 02:05
@graphite-app graphite-app Bot merged commit 4ab16d1 into main May 12, 2026
29 of 33 checks passed
@graphite-app graphite-app Bot deleted the 04-28-fix_dev_lazy_fix_exports_of_lazy_requests_in_lazy_chunks branch May 12, 2026 02:09
@rolldown-guard rolldown-guard Bot mentioned this pull request May 13, 2026
shulaoda added a commit that referenced this pull request May 13, 2026
## [1.0.1] - 2026-05-13

### 🚀 Features

- experimental/lazy-barrel: advice on oversized barrel modules (#9236) by @shulaoda
- rolldown: inline optional-chain enum access (#9379) by @Dunqing
- chunk-optimization: dedupe already-loaded dynamic deps (#9305) by @IWANABETHATGUY
- binding: call moduleParsed hook in ParallelJsPlugin (#9318) by @jaehafe

### 🐛 Bug Fixes

- transform: enable `enum_eval` for `transformSync` and vite TS transform (#9325) by @Dunqing
- error: remove severity prefix from diagnostic messages (#9262) by @Kyujenius
- deps: pin pnpm to 10.23.0 to work around catalog mismatch on Netlify (#9364) by @shulaoda
- ci: pin mimalloc-safe to 0.1.58 (#9361) by @shulaoda
- dev/lazy: fix exports of lazy requests in lazy chunks (#9249) by @h-a-n-a
- rolldown_plugin_vite_resolve: handle errors in `resolveSubpathImports` callback (#9355) by @sapphi-red
- rolldown_plugin_lazy_compilation: use loadExports for fetched proxy to preserve original export names (#9132) by @h-a-n-a
- common: include offending index in HybridIndexVec panic message (#9296) by @SAY-5

### 🚜 Refactor

- ecmascript: extract semantic_builder_for_transform helper (#9326) by @Dunqing
- test: extract reusable static-import-cycle helper (#9332) by @IWANABETHATGUY

### 📚 Documentation

- clarify scope of `topLevelVar` (#9380) by @IWANABETHATGUY
- meta/design: add ast-mutation design doc (#9338) by @hyf0
- feat: add ai policy in contribution guide (#9315) by @mdong1909

### ⚡ Performance

- binding: enable mimalloc v3 to reduce idle memory (#9349) by @shulaoda

### 🧪 Testing

- mcs: cover require() in `$initial` group (#9376) by @hyf0
- add regression for CJS facade chunk merge into entry (#9351) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- switch prepare-release to manual dispatch with version input (#9383) by @shulaoda
- migrate `@rolldown/pluginutils` to `rolldown/plugins` (#9317) by @shulaoda
- deps: pin libmimalloc-sys2 to 0.1.54 (#9372) by @shulaoda
- replace `igorskyflyer/action-readfile` with `cat` (#9369) by @sapphi-red
- deps: update test262 submodule for tests (#9371) by @rolldown-guard[bot]
- use app token for test dep update PRs (#9368) by @sapphi-red
- replace some actions with gh commands (#9367) by @sapphi-red
- replace action-semantic-pull-request with inline regex (#9366) by @sapphi-red
- remove pull_request_target workflows (#9188) by @Boshen
- deps: upgrade oxc to 0.130.0 (#9360) by @shulaoda
- deps: update github actions (major) (#9348) by @renovate[bot]
- deps: update github actions (#9341) by @renovate[bot]
- deps: update rust crates (#9344) by @renovate[bot]
- deps: update crate-ci/typos action to v1.46.1 (#9357) by @renovate[bot]
- deps: update npm packages (#9343) by @renovate[bot]
- deps: update pnpm to v10.33.4 (#9347) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.25.0 (#9346) by @renovate[bot]
- .claude: add rolldown-repl encoder, rename decode skill (#9352) by @IWANABETHATGUY
- deps: update crate-ci/typos action to v1.46.0 (#9345) by @renovate[bot]
- deps: update napi to v3.8.6 (#9342) by @renovate[bot]
- deps: update dependency vite-plus to v0.1.20 (#9340) by @renovate[bot]
- enable rollup chunking-form test (#9335) by @IWANABETHATGUY
- typo: fix typo in watcher options comment (#9324) by @thescripted

### ❤️ New Contributors

* @Kyujenius made their first contribution in [#9262](#9262)
* @SAY-5 made their first contribution in [#9296](#9296)
* @thescripted made their first contribution in [#9324](#9324)

Co-authored-by: shulaoda <[email protected]>
IWANABETHATGUY pushed a commit that referenced this pull request May 18, 2026
## Summary

This PR fixes a case where dynamic imported chunks in lazy chunks are not able to fetch the correct exports.

Before:

```js
import(`/@vite/lazy?id=…&clientId=…`)
```

After:

```js
import(`/@vite/lazy?id=…&clientId=…`)
    .then(() => __rolldown_runtime__.loadExports("<stable_proxy_id>"))
```

When a lazy chunk's body contains `import('./another-lazy.js')`, the HMR partial
bundle returned the raw chunk namespace (raw lazy chunk) instead of the registered proxy exports,
so `inner.foo` came back `undefined`.

In this PR, we intentionally skip loading the raw lazy chunk, instead,
we use `__rolldown_runtime__.loadExports(...)` to load real module exports.

## Test plan

- [x] `pnpm test:browser` — all 7 tests pass with the fix in place
- [x] New playground: `packages/test-dev-server/tests/playground/lazy-nested-dynamic-import/`
- [x] Reverted the fix locally → `pnpm test:browser -t 'lazy-nested-dynamic-import'` fails with
`inner.foo = UNDEFINED` / `inner.bar = UNDEFINED`
- [x] Restored the fix → test passes on first try (~135 ms, no retry)
- [x] `pnpm run lint-knip` clean for the new playground
IWANABETHATGUY pushed a commit that referenced this pull request May 18, 2026
## [1.0.1] - 2026-05-13

### 🚀 Features

- experimental/lazy-barrel: advice on oversized barrel modules (#9236) by @shulaoda
- rolldown: inline optional-chain enum access (#9379) by @Dunqing
- chunk-optimization: dedupe already-loaded dynamic deps (#9305) by @IWANABETHATGUY
- binding: call moduleParsed hook in ParallelJsPlugin (#9318) by @jaehafe

### 🐛 Bug Fixes

- transform: enable `enum_eval` for `transformSync` and vite TS transform (#9325) by @Dunqing
- error: remove severity prefix from diagnostic messages (#9262) by @Kyujenius
- deps: pin pnpm to 10.23.0 to work around catalog mismatch on Netlify (#9364) by @shulaoda
- ci: pin mimalloc-safe to 0.1.58 (#9361) by @shulaoda
- dev/lazy: fix exports of lazy requests in lazy chunks (#9249) by @h-a-n-a
- rolldown_plugin_vite_resolve: handle errors in `resolveSubpathImports` callback (#9355) by @sapphi-red
- rolldown_plugin_lazy_compilation: use loadExports for fetched proxy to preserve original export names (#9132) by @h-a-n-a
- common: include offending index in HybridIndexVec panic message (#9296) by @SAY-5

### 🚜 Refactor

- ecmascript: extract semantic_builder_for_transform helper (#9326) by @Dunqing
- test: extract reusable static-import-cycle helper (#9332) by @IWANABETHATGUY

### 📚 Documentation

- clarify scope of `topLevelVar` (#9380) by @IWANABETHATGUY
- meta/design: add ast-mutation design doc (#9338) by @hyf0
- feat: add ai policy in contribution guide (#9315) by @mdong1909

### ⚡ Performance

- binding: enable mimalloc v3 to reduce idle memory (#9349) by @shulaoda

### 🧪 Testing

- mcs: cover require() in `$initial` group (#9376) by @hyf0
- add regression for CJS facade chunk merge into entry (#9351) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- switch prepare-release to manual dispatch with version input (#9383) by @shulaoda
- migrate `@rolldown/pluginutils` to `rolldown/plugins` (#9317) by @shulaoda
- deps: pin libmimalloc-sys2 to 0.1.54 (#9372) by @shulaoda
- replace `igorskyflyer/action-readfile` with `cat` (#9369) by @sapphi-red
- deps: update test262 submodule for tests (#9371) by @rolldown-guard[bot]
- use app token for test dep update PRs (#9368) by @sapphi-red
- replace some actions with gh commands (#9367) by @sapphi-red
- replace action-semantic-pull-request with inline regex (#9366) by @sapphi-red
- remove pull_request_target workflows (#9188) by @Boshen
- deps: upgrade oxc to 0.130.0 (#9360) by @shulaoda
- deps: update github actions (major) (#9348) by @renovate[bot]
- deps: update github actions (#9341) by @renovate[bot]
- deps: update rust crates (#9344) by @renovate[bot]
- deps: update crate-ci/typos action to v1.46.1 (#9357) by @renovate[bot]
- deps: update npm packages (#9343) by @renovate[bot]
- deps: update pnpm to v10.33.4 (#9347) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to ^0.25.0 (#9346) by @renovate[bot]
- .claude: add rolldown-repl encoder, rename decode skill (#9352) by @IWANABETHATGUY
- deps: update crate-ci/typos action to v1.46.0 (#9345) by @renovate[bot]
- deps: update napi to v3.8.6 (#9342) by @renovate[bot]
- deps: update dependency vite-plus to v0.1.20 (#9340) by @renovate[bot]
- enable rollup chunking-form test (#9335) by @IWANABETHATGUY
- typo: fix typo in watcher options comment (#9324) by @thescripted

### ❤️ New Contributors

* @Kyujenius made their first contribution in [#9262](#9262)
* @SAY-5 made their first contribution in [#9296](#9296)
* @thescripted made their first contribution in [#9324](#9324)

Co-authored-by: shulaoda <[email protected]>
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.

2 participants