Skip to content

Comments

feat(hmr): introduce rolldown_plugin_hmr to inject runtime code#5159

Merged
hyf0 merged 1 commit intomainfrom
07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code
Jul 4, 2025
Merged

feat(hmr): introduce rolldown_plugin_hmr to inject runtime code#5159
hyf0 merged 1 commit intomainfrom
07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Jul 4, 2025

  • rolldown:hmr is treated as a normal module. Users can't observe it via plugin hooks, because we process it in advance in rolldown_plugin_hmr.
  • I'm also using rolldown:hmr as a case to explore what's the proper way to handle runtime module.

@hyf0 hyf0 marked this pull request as ready for review July 4, 2025 07:15
@netlify
Copy link

netlify bot commented Jul 4, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit a809770
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/68678247b98c3700082bb674

@hyf0 hyf0 force-pushed the 07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code branch from f106239 to 1294a02 Compare July 4, 2025 07:20
@hyf0 hyf0 requested a review from sapphi-red July 4, 2025 07:20
@hyf0 hyf0 force-pushed the 07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code branch from 1294a02 to a809770 Compare July 4, 2025 07:27
@hyf0 hyf0 requested a review from IWANABETHATGUY July 4, 2025 07:27
@github-actions
Copy link
Contributor

github-actions bot commented Jul 4, 2025

Benchmarks Rust

  • target: main(84263e1)
  • pr: 07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code(a809770)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.01     84.1±6.51ms        ? ?/sec    1.00     83.2±5.05ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     91.3±3.03ms        ? ?/sec    1.04     94.9±5.93ms        ? ?/sec
bundle/bundle@rome_ts                                        1.03    120.7±5.49ms        ? ?/sec    1.00    117.1±3.76ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.01    141.5±4.73ms        ? ?/sec    1.00    140.0±4.12ms        ? ?/sec
bundle/bundle@threejs                                        1.02     44.3±3.11ms        ? ?/sec    1.00     43.4±1.79ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.01     53.6±2.26ms        ? ?/sec    1.00     53.2±2.19ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    442.5±3.67ms        ? ?/sec    1.02   449.2±10.19ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.03   528.8±12.37ms        ? ?/sec    1.00    513.2±6.60ms        ? ?/sec
scan/scan@rome_ts                                            1.01     93.7±3.19ms        ? ?/sec    1.00     93.1±3.32ms        ? ?/sec
scan/scan@threejs                                            1.05     32.4±2.05ms        ? ?/sec    1.00     30.8±0.45ms        ? ?/sec
scan/scan@threejs10x                                         1.00    329.7±4.45ms        ? ?/sec    1.02    337.0±5.86ms        ? ?/sec

@sapphi-red
Copy link
Member

  • Users can't observe it via plugin hooks, because we process it in advance in rolldown_plugin_hmr.

Isn't it possible to observe / modify rolldown:hmr by the transform hook?

@IWANABETHATGUY
Copy link
Member

Looks good to me, wait @sapphi-red to have a look.

@hyf0
Copy link
Member Author

hyf0 commented Jul 4, 2025

  • Users can't observe it via plugin hooks, because we process it in advance in rolldown_plugin_hmr.

Isn't it possible to observe / modify rolldown:hmr by the transform hook?

I forget about this one. Do you think it's ok we allow this behavior or I could do a hard-code to not allow this behavio by making modules starts with rolldown: won't go through transform hook?

@sapphi-red
Copy link
Member

  • Users can't observe it via plugin hooks, because we process it in advance in rolldown_plugin_hmr.

Isn't it possible to observe / modify rolldown:hmr by the transform hook?

I forget about this one. Do you think it's ok we allow this behavior or I could do a hard-code to not allow this behavio by making modules starts with rolldown: won't go through transform hook?

I guess it's ok to allow the behavior.

By the way, how would rolldown:hmr be used?

Copy link
Member Author

hyf0 commented Jul 4, 2025

By the way, how would rolldown:hmr be used?

See #5162

@hyf0 hyf0 added this pull request to the merge queue Jul 4, 2025
Merged via the queue into main with commit c634a8b Jul 4, 2025
24 checks passed
@hyf0 hyf0 deleted the 07-04-feat_hmr_introduce_rolldown_plugin_hmr_to_inject_runtime_code branch July 4, 2025 10:23
github-merge-queue bot pushed a commit that referenced this pull request Jul 5, 2025
…5169)

Discussed at
#5159 (comment).

On reflection, I think it's better to not allow it in the first place.
Considering possible `rolldown:oxc-runtime` in the future, it's not a
good idea to let users modify internal modules' code. @sapphi-red cc

However, if we do require this in the future, we could rethink this
decision.
@github-actions github-actions bot mentioned this pull request Jul 5, 2025
hyf0 pushed a commit that referenced this pull request Jul 5, 2025
## [1.0.0-beta.24] - 2025-07-05

### 🚀 Features

- support `inlineConst` for imported variable (#5165) by @IWANABETHATGUY
- rust: skip transform hook for modules starts with `rolldown:` (#5169)
by @hyf0
- print rolldown version (#5163) by @btea
- add optimization.inlineConst option (#5164) by @IWANABETHATGUY
- hmr: introduce `rolldown_plugin_hmr` to inject runtime code (#5159) by
@hyf0
- rolldown: oxc v0.75.1 (#5157) by @Boshen

### 🐛 Bug Fixes

- generate correct CSS filename in `preserveModules` mode (#5175) by
@shulaoda
- rolldown_plugin_build_import_analysis: avoid `default` keyword error
(#5166) by @shulaoda
- watch: add paths to watcher in batch (#5068) by @branchseer
- debug: should emit chunk data after computing cross chunk links
(#5156) by @hyf0
- simplify commonjs interop `default` prop optimization (#5142) by
@IWANABETHATGUY
- should include modules contain `exports * from '...'` forcefully if
they reexport any wrapped module (#5143) by @hyf0
- use canonical runtime time for `__name` (#5140) by @IWANABETHATGUY
- `options.jsx` is ignored when `options.transform` is set (#5137) by
@shulaoda

### 🚜 Refactor

- polyfill `flatten_iter` for wasm target (#5180) by @IWANABETHATGUY
- rolldown_plugin_dynamic_import_vars: remove unnecessary validity
checks (#5172) by @shulaoda
- hmr: remove hmr-related hacky hard-code (#5168) by @hyf0
- rolldown_plugin_dynamic_import_vars: align with rolldown-vite (#5171)
by @shulaoda
- hmr: use `rolldown:hmr` to load hmr runtime code (#5162) by @hyf0
- rust: remove special fields of `Asset` (#5155) by @hyf0
- rust: make `Asset#originate_from` optional (#5153) by @hyf0
- rust: isolate mutations on assets data (#5152) by @hyf0
- rust: remove unnecessary usage of index vec on assets (#5151) by @hyf0
- merge different member expr in `try_rewrite_member_expr` (#5146) by
@IWANABETHATGUY
- remove unused code (#5144) by @IWANABETHATGUY
- use `self.result.ast_usage` directly (#5135) by @IWANABETHATGUY

### 📚 Documentation

- update syntax lowering transform info (#5145) by @TheAlexLichter

### 🧪 Testing

- rust/hmr: hide hmr runtime code in snapshots (#5160) by @hyf0

### ⚙️ Miscellaneous Tasks

- rolldown_testing: avoid unnecessary snapshots (#5181) by @shulaoda
- fix `flatten_iter` compile error (#5179) by @IWANABETHATGUY
- expose `optimization.inlineConst` option (#5177) by @IWANABETHATGUY
- infra: update `pnpm-lock.yaml` (#5178) by @shulaoda
- rust: remove unnecessary crate `rolldown_loader_utils` (#5173) by
@shulaoda
- print build time use green color (#5158) by @btea
- deps: update dependency rolldown-plugin-dts to v0.13.13 (#5148) by
@renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.13.13 (#5138) by
@renovate[bot]
- allow only test without generate snapshot (#5134) by @IWANABETHATGUY

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.

3 participants