Skip to content

Comments

feat(dev/lazy): support dynamic import(..)#7726

Merged
graphite-app[bot] merged 1 commit intomainfrom
hyf_lazy_new
Jan 5, 2026
Merged

feat(dev/lazy): support dynamic import(..)#7726
graphite-app[bot] merged 1 commit intomainfrom
hyf_lazy_new

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Dec 31, 2025

Same as #7609 but use stable module id instead of module id.

@hyf0 hyf0 changed the title refactor(dev): use direct module id instead of stable id feat(dev/lazy): use direct module id instead of stable id Dec 31, 2025
Copy link
Member Author

hyf0 commented Dec 31, 2025


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.

@hyf0 hyf0 changed the title feat(dev/lazy): use direct module id instead of stable id feat(dev/lazy): support dynamic import(..) Dec 31, 2025
@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 51485c6
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69556a80a1ba2b0008ce895e
😎 Deploy Preview https://deploy-preview-7726--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.

@netlify
Copy link

netlify bot commented Dec 31, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit e8e1c20
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/695bb8086eee90000834c905

@hyf0 hyf0 force-pushed the hyf_lazy_new branch 2 times, most recently from b199341 to ecfdf0c Compare January 1, 2026 12:00
@hyf0 hyf0 requested a review from sapphi-red January 1, 2026 20:45
@hyf0 hyf0 marked this pull request as ready for review January 1, 2026 20:45
Copilot AI review requested due to automatic review settings January 1, 2026 20:45
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.

Pull request overview

This PR implements lazy compilation for dynamic imports in development mode, allowing modules imported via import() to be compiled on-demand rather than at build time. This optimization aims to improve development cold start times.

Key changes:

  • Adds lazy compilation plugin that creates proxy modules for dynamic imports
  • Implements /lazy HTTP endpoint to serve on-demand compiled modules
  • Integrates lazy compilation state tracking into DevEngine and bundle coordinator
  • Adds runtime support for client ID management and proxy module unwrapping

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
crates/rolldown_plugin_lazy_compilation/ Core plugin implementing lazy compilation with proxy modules and state tracking
crates/rolldown_dev/src/dev_engine.rs Adds compile_lazy_entry method and module change notifications
crates/rolldown_dev/src/bundle_coordinator.rs Handles programmatic module changes to trigger rebuilds
packages/test-dev-server/src/dev-server.ts Implements /lazy endpoint and client ID management
crates/rolldown/src/hmr/hmr_stage.rs Adds lazy entry compilation with partial scan support
crates/rolldown/src/hmr/hmr_ast_finalizer.rs Supports computed property syntax for non-identifier exports
examples/lazy/ Example demonstrating lazy compilation feature
pnpm-lock.yaml Lock file updates for new example dependencies
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 1, 2026

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     63.3±2.58ms        ? ?/sec    1.07     67.7±1.56ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     69.4±1.89ms        ? ?/sec    1.10     76.2±1.35ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    106.4±3.03ms        ? ?/sec    1.01    107.0±2.47ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    118.3±1.58ms        ? ?/sec    1.02    121.2±2.36ms        ? ?/sec
bundle/bundle@threejs                                        1.00     39.2±1.31ms        ? ?/sec    1.01     39.5±1.97ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     44.7±0.77ms        ? ?/sec    1.00     44.6±0.54ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    388.7±3.35ms        ? ?/sec    1.03    401.6±6.49ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    458.2±4.07ms        ? ?/sec    1.02    467.7±3.39ms        ? ?/sec
scan/scan@rome_ts                                            1.00     80.8±1.23ms        ? ?/sec    1.02     82.8±1.73ms        ? ?/sec
scan/scan@threejs                                            1.00     28.3±1.76ms        ? ?/sec    1.02     28.7±1.81ms        ? ?/sec
scan/scan@threejs10x                                         1.00    282.6±3.09ms        ? ?/sec    1.02    287.2±4.26ms        ? ?/sec

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.

Pull request overview

Copilot reviewed 38 out of 40 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 5, 2026

Merge activity

  • Jan 5, 12:23 PM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Jan 5, 12:23 PM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Jan 5, 12:24 PM 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.
  • Jan 5, 12:45 PM UTC: graphite-app added this pull request to the Graphite merge queue.
  • Jan 5, 12:46 PM UTC: The Graphite merge queue couldn't merge this PR because it had merge conflicts.
  • Jan 5, 1:08 PM 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.
  • Jan 5, 1:08 PM UTC: shulaoda added this pull request to the Graphite merge queue.
  • Jan 5, 1:19 PM UTC: Merged by the Graphite merge queue.

Same as #7609 but use stable module id instead of module id.
@graphite-app graphite-app bot merged commit e8e1c20 into main Jan 5, 2026
34 checks passed
@graphite-app graphite-app bot deleted the hyf_lazy_new branch January 5, 2026 13:19
This was referenced Jan 7, 2026
shulaoda added a commit that referenced this pull request Jan 7, 2026
## [1.0.0-beta.59] - 2026-01-07

⚡ Inline Dynamic Imports for Statically Imported Modules

- When a module is already statically imported, dynamic imports to that same module are now inlined instead of creating a separate chunk

### 🚀 Features

- plugin_timings: add 3s threshold and doc link to warning message (#7741) by @shulaoda
- improve treeshaking logic to handle empty parameter list in dynamic import .then() callbacks (#7781) by @Copilot
- dev/lazy: don't include already executed modules (#7745) by @hyf0
- dev/lazy: support dynamic `import(..)` (#7726) by @hyf0
- inline dynamic imports that imports statically imported modules (#7742) by @IWANABETHATGUY
- option: add experimental option to control chunk optimization (#7738) by @IWANABETHATGUY

### 🐛 Bug Fixes

- inline dynamic entry to user defined entry with esm wrap kind (#7783) by @IWANABETHATGUY
- use canonical namespace reference for property access (#7777) by @IWANABETHATGUY
- dynamic entry merged into common chunk with cjs and esm wrap kind (#7771) by @IWANABETHATGUY
- tla: should not await non-tla-related modules (#7768) by @hyf0
- dynamic entry captured by common chunk with CJS format (#7757) by @IWANABETHATGUY
- module_loader: mark emitted chunks as user-defined entry when already loaded (#7765) by @shulaoda
- normalize preserveModulesRoot path (#7737) by @IWANABETHATGUY
- linker: resolve race condition in side effects computation for export-star (#7728) by @camc314

### 🚜 Refactor

- plugin_timings: filter out plugins with duration < 1s from timing warnings (#7785) by @shulaoda
- module_loader: remove unnecessary collect before extend (#7769) by @shulaoda
- rename _id suffixes to _idx for oxc_index types (#7767) by @IWANABETHATGUY
- remove duplicate `preserve_entry_signatures` from `AddEntryModuleMsg` (#7762) by @shulaoda
- module_loader: pass `user_defined_entries` by reference (#7756) by @shulaoda
- dev/lazy: get proxy entry's `ResolvedId` correctly (#7746) by @hyf0
- simplify try_rewrite_import_expression control flow (#7753) by @IWANABETHATGUY
- module_loader: remove unnecessary dynamic import handling for runtime module (#7754) by @shulaoda
- inline __toDynamicImportESM  (#7747) by @IWANABETHATGUY
- use From impl for ModuleLoaderOutput conversion (#7732) by @shulaoda
- remove duplicate fields from `ModuleLoader` (#7731) by @shulaoda
- tweak `resolve_user_defined_entries` (#7727) by @shulaoda

### 📚 Documentation

- add rolldown-string reference to native MagicString compatibility section (#7778) by @Copilot
- improve comments for export star side effects handling (#7730) by @IWANABETHATGUY

### 🧪 Testing

- use assertion instead of console.log for some testcase (#7744) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- tweak some `output.dynamicImportInCjs` related rollup test results (#7776) by @sapphi-red
- mark esbuild/dce/dce_of_symbol_ctor_call as passed (#7775) by @sapphi-red
- deps: update oxc apps (#7772) by @renovate[bot]
- vite-tests: allow running on PRs with `test: vite-tests` label (#7770) by @shulaoda
- deps: update oxc apps (#7760) by @renovate[bot]
- deps: update rollup submodule for tests to v4.55.1 (#7763) by @sapphi-red
- deps: update test262 submodule for tests (#7764) by @sapphi-red
- deps: update oxc to v0.107.0 (#7758) by @camc314
- deps: update taiki-e/install-action action to v2.65.13 (#7751) by @renovate[bot]
- deps: update rust crates (#7750) by @renovate[bot]
- deps: update npm packages (#7749) by @renovate[bot]
- deps: update github-actions (#7748) by @renovate[bot]
- deps: update dependency oxlint-tsgolint to v0.10.1 (#7729) by @renovate[bot]
- deps: update crate-ci/typos action to v1.41.0 (#7725) by @renovate[bot]

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