Skip to content

Comments

feat(dev/lazy): inject lazy compilation runtime automatically#7816

Merged
graphite-app[bot] merged 1 commit intomainfrom
01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically
Jan 9, 2026
Merged

feat(dev/lazy): inject lazy compilation runtime automatically#7816
graphite-app[bot] merged 1 commit intomainfrom
01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Jan 9, 2026

No description provided.

Copy link
Member Author

hyf0 commented Jan 9, 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.

@hyf0 hyf0 marked this pull request as ready for review January 9, 2026 08:32
@hyf0 hyf0 requested review from Copilot and sapphi-red and removed request for Copilot January 9, 2026 08:32
Copilot AI review requested due to automatic review settings January 9, 2026 08:47
@hyf0 hyf0 force-pushed the 01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically branch from b57b300 to b555338 Compare January 9, 2026 08:47
@hyf0 hyf0 force-pushed the 01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically branch from b555338 to 1b63037 Compare January 9, 2026 08:51
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 automatic runtime injection for lazy compilation, eliminating the need for users to manually unwrap lazy module exports. The plugin now automatically wraps all dynamic imports with a helper function that transparently unwraps the rolldown:exports promise for lazy modules while passing through regular modules unchanged.

Key changes:

  • New runtime_injector.rs module that uses oxc AST visitor to transform dynamic imports
  • Updated lazy_compilation_plugin.rs to register and implement transform_ast hook
  • Removed manual lazyMagic helper from example code, demonstrating the improved DX

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/rolldown_plugin_lazy_compilation/src/runtime_injector.rs New module implementing AST visitor to transform dynamic imports and generate the unwrap helper function
crates/rolldown_plugin_lazy_compilation/src/lazy_compilation_plugin.rs Added transform_ast hook implementation with directive prologue handling
crates/rolldown_plugin_lazy_compilation/src/lib.rs Exports the new runtime_injector module
crates/rolldown_plugin_lazy_compilation/Cargo.toml Added oxc dependency for AST manipulation
examples/lazy/src/entry-a.js Removed manual lazyMagic helper, uses standard dynamic imports
examples/lazy/src/async-entry-a.js Added shared module import, updated output formatting
examples/lazy/src/async-entry-b.js Added shared module import, added DOM output
examples/lazy/src/async-lib-a.js Updated string formatting for consistency
examples/lazy/src/async-lib-b.js Updated string formatting for consistency
examples/lazy/src/async-lib-shared.js New shared module to test lazy compilation with shared dependencies
examples/lazy/lazy-compilation.md Comprehensive documentation updates explaining the automatic unwrapping mechanism
packages/test-dev-server/src/dev-server.ts Added timing logs for initial build (acceptable for test utility)
crates/rolldown/src/hmr/hmr_stage.rs Added debug println statement (should be removed or converted to proper logging)
deny.toml Added advisory ignore for unmaintained bincode dependency
Cargo.lock Updated with new oxc dependency

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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Benchmarks Rust

  • target: 01-07-fix_dev_lazy_should_include_imported_and_non-executed_modules_in_the_patch(d9615cd)
  • pr: 01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically(1b63037)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     63.7±1.97ms        ? ?/sec    1.06     67.5±2.36ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     70.2±2.00ms        ? ?/sec    1.06     74.4±2.49ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    106.2±2.76ms        ? ?/sec    1.00    106.3±1.90ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    117.1±2.23ms        ? ?/sec    1.02    119.2±2.69ms        ? ?/sec
bundle/bundle@threejs                                        1.00     38.0±0.87ms        ? ?/sec    1.02     38.7±2.21ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     42.5±0.71ms        ? ?/sec    1.02     43.4±0.81ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    388.4±5.13ms        ? ?/sec    1.01    391.9±4.19ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    448.4±7.58ms        ? ?/sec    1.01    454.3±5.27ms        ? ?/sec
scan/scan@rome_ts                                            1.00     83.6±1.82ms        ? ?/sec    1.04     87.0±1.82ms        ? ?/sec
scan/scan@threejs                                            1.00     28.6±1.66ms        ? ?/sec    1.01     28.9±0.58ms        ? ?/sec
scan/scan@threejs10x                                         1.00    292.1±4.82ms        ? ?/sec    1.02    298.5±5.21ms        ? ?/sec

Copy link
Member Author

hyf0 commented Jan 9, 2026

Merge activity

@graphite-app graphite-app bot changed the base branch from 01-07-fix_dev_lazy_should_include_imported_and_non-executed_modules_in_the_patch to graphite-base/7816 January 9, 2026 12:02
@graphite-app graphite-app bot changed the base branch from graphite-base/7816 to main January 9, 2026 12:13
@graphite-app graphite-app bot force-pushed the 01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically branch from 1b63037 to f923f68 Compare January 9, 2026 12:14
@netlify
Copy link

netlify bot commented Jan 9, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit f923f68
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6960f12a7c7e260008ac0f9a

@graphite-app graphite-app bot merged commit f923f68 into main Jan 9, 2026
35 checks passed
@graphite-app graphite-app bot deleted the 01-09-feat_dev_lazy_inject_lazy_compilation_runtime_automatically branch January 9, 2026 12:24
This was referenced Jan 14, 2026
shulaoda added a commit that referenced this pull request Jan 14, 2026
## [1.0.0-beta.60] - 2026-01-14

### 💥 BREAKING CHANGES

- tsconfig: enable auto-discovery by default (#7817) by @shulaoda

### 🚀 Features

- distinguish transformer diagnostics from parse errors (#7872) by @shulaoda
- emit transformer warnings instead of ignoring them (#7850) by @shulaoda
- node: add `output.codeSplitting` option and deprecate `output.advancedChunks` (#7855) by @hyf0
- nativeMagicString reset (#7828) by @IWANABETHATGUY
- nativeMagicString lastChar (#7819) by @IWANABETHATGUY
- dev/lazy: inject lazy compilation runtime automatically (#7816) by @hyf0
- nativeMagicString snip (#7818) by @IWANABETHATGUY
- nativeMagicString construct with options (#7814) by @IWANABETHATGUY
- nativeMagicString clone (#7813) by @IWANABETHATGUY
- nativeMagicString `insert` (#7812) by @IWANABETHATGUY
- nativeMagicString `slice` (#7807) by @IWANABETHATGUY
- nativeMagicString trim methods (#7800) by @IWANABETHATGUY
- make closeBundle hook receive the last error (#7278) by @Copilot

### 🐛 Bug Fixes

- when package only contains export default, cjsDefault didn't resolve correctly (#7873) by @IWANABETHATGUY
- inline __name calls for default exports  (#7862) by @IWANABETHATGUY
- improve variable renaming to avoid unnecessary shadowing in nested scopes (#7859) by @IWANABETHATGUY
- use correct index when inserting keepNames statements during export default transformation (#7853) by @IWANABETHATGUY
- transform non-static dynamic imports when `dynamicImportInCjs` is `false` (#7823) by @shulaoda
- dev/lazy: should include imported and non-executed modules in the patch (#7815) by @hyf0
- set ExportsKind to Esm when json is none object literal  (#7808) by @IWANABETHATGUY
- nativeMagicString move api (#7796) by @IWANABETHATGUY
- remove unnecessary exports after merging into commong and user defined entry (#7789) by @IWANABETHATGUY
- use output.name instead of chunk.name in mixed export warning (#7788) by @Copilot

### 🚜 Refactor

- generalize ParseError to OxcError with dynamic EventKind (#7868) by @shulaoda
- rust: rename `advanced_chunks` to `manual_code_splitting` (#7856) by @hyf0
- string_wizard error hanlding (#7830) by @IWANABETHATGUY
- remove `experimental.disableLiveBindings` option (#7820) by @sapphi-red
- node/test: run fixture tests in concurrent (#7790) by @hyf0
- move ConfigExport and RolldownOptionsFunction types to define-config (#7799) by @shulaoda
- cli: validate config after resolving and improve error message (#7798) by @shulaoda

### 📚 Documentation

- rebrand (#7670) by @yyx990803
- fix incorrect default value for propertyReadSideEffects (#7847) by @Copilot
- remove options pages and redirect to reference pages (#7834) by @sapphi-red
- options: inline types to option property pages (#7831) by @sapphi-red
- options: port checks.pluginTimings content from options page to reference page (#7832) by @sapphi-red
- options: use `@linkcode` where possible (#7824) by @sapphi-red
- options: port content from options page to reference page (#7822) by @sapphi-red
- options: add descriptions for output options (#7821) by @sapphi-red
- options: add description for input options (#7802) by @sapphi-red
- options: add description for `checks.*` (#7801) by @sapphi-red
- apis: add hook graph (#7671) by @sapphi-red

### 🧪 Testing

- add all valid combination of chunk exports related test (#7851) by @IWANABETHATGUY
- enable MagicString test after api return type alignment (#7797) by @IWANABETHATGUY
- init magic-string test (#7794) by @IWANABETHATGUY

### ⚙️ Miscellaneous Tasks

- vite-tests: configure git user for rebase operation (#7875) by @shulaoda
- rolldown_binding: remove v3 native plugins (#7837) by @shulaoda
- rolldown_binding: allow crate-type as lib (#7866) by @Brooooooklyn
- README.md: adjust position and size of rolldown logo (#7861) by @hyf0
- deps: update test262 submodule for tests (#7857) by @sapphi-red
- deps: update oxc to v0.108.0 (#7845) by @renovate[bot]
- deps: update dependency oxlint to v1.39.0 (#7849) by @renovate[bot]
- deps: update dependency oxfmt to ^0.24.0 (#7844) by @renovate[bot]
- deps: update npm packages (#7841) by @renovate[bot]
- deps: update rust crates (#7839) by @renovate[bot]
- deps: update github-actions (#7840) by @renovate[bot]
- use workspace edition for all crates (#7829) by @IWANABETHATGUY
- deps: update dependency oxlint-tsgolint to v0.11.0 (#7827) by @renovate[bot]
- deps: update napi to v3.8.2 (#7810) by @renovate[bot]
- remove outdated snapshot files (#7806) by @shulaoda
- deps: update crate-ci/typos action to v1.42.0 (#7792) 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