Skip to content

Comments

feat(hmr): handle import.meta.hot.invalidate#4339

Merged
underfin merged 1 commit intomainfrom
04-27-feat_hmr_handle_import.meta.hot
Apr 30, 2025
Merged

feat(hmr): handle import.meta.hot.invalidate#4339
underfin merged 1 commit intomainfrom
04-27-feat_hmr_handle_import.meta.hot

Conversation

@underfin
Copy link
Contributor

@underfin underfin commented Apr 27, 2025

Description

The vite hmr has hmr invalidate feature, it is mark the self accpeting hmr module can't process update, using the API to the update needs to be forcefully propagated to importers. ref https://vite.dev/guide/api-hmr#hot-invalidate-message-string.

import.meta.hot.accept(() => {
    // Trigger HMR in importers
    import.meta.hot.invalidate()
})

The vite implement.

  • the self accepting module change, the hmr boundary is the module
  • hmr runtime to execute import.meta.hot.accept callback, so the import.meta.hot.invalidate is called, and then the API will be send a msg vite:invalidate to the server. The reason is the client hasn't module graph.
  • the server using the importer of invalidate module to propagateUpdate

The rolldown esm hmr is follow the vite implement. The rolldown-vite receiver vite:invalidate was msg will call rolldownBuild.hmrInvalidate to execute rolldown internal propagateUpdate.

related rolldown-vite commit

Copy link
Contributor Author

underfin commented Apr 27, 2025

@underfin underfin changed the title feat(hmr): handle import.meta.hot feat(hmr): handle import.meta.hot.invalidate Apr 27, 2025
@underfin underfin force-pushed the 04-27-feat_hmr_handle_import.meta.hot branch from f421616 to f126fd5 Compare April 27, 2025 07:20
@github-actions
Copy link
Contributor

github-actions bot commented Apr 27, 2025

Benchmarks Rust

  • target: main(21b9e45)
  • pr: 04-27-feat_hmr_handle_import.meta.hot(e0fc27a)
group                                                               pr                                     target
-----                                                               --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol                     1.00     79.2±2.41ms        ? ?/sec    1.01     80.3±2.38ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify              1.00     97.9±1.49ms        ? ?/sec    1.01     98.8±2.28ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify-sourcemap    1.00    111.4±1.45ms        ? ?/sec    1.04    115.5±3.21ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap           1.00     89.5±3.02ms        ? ?/sec    1.01     90.2±2.37ms        ? ?/sec
bundle/bundle@rome-ts                                               1.00    122.0±1.44ms        ? ?/sec    1.02    124.1±3.04ms        ? ?/sec
bundle/bundle@rome-ts-minify                                        1.00    196.9±2.84ms        ? ?/sec    1.05    206.3±5.18ms        ? ?/sec
bundle/bundle@rome-ts-minify-sourcemap                              1.00    244.4±5.75ms        ? ?/sec    1.03    252.0±8.89ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap                                     1.02    137.2±4.08ms        ? ?/sec    1.00    135.2±1.27ms        ? ?/sec
bundle/bundle@threejs                                               1.00     41.8±0.72ms        ? ?/sec    1.00     41.8±1.36ms        ? ?/sec
bundle/bundle@threejs-minify                                        1.00     85.9±2.41ms        ? ?/sec    1.01     86.8±2.04ms        ? ?/sec
bundle/bundle@threejs-minify-sourcemap                              1.00    102.2±2.72ms        ? ?/sec    1.03    105.7±3.11ms        ? ?/sec
bundle/bundle@threejs-sourcemap                                     1.00     49.3±1.10ms        ? ?/sec    1.02     50.1±0.64ms        ? ?/sec
bundle/bundle@threejs10x                                            1.00    423.3±3.71ms        ? ?/sec    1.01    426.9±6.25ms        ? ?/sec
bundle/bundle@threejs10x-minify                                     1.00  1043.8±10.94ms        ? ?/sec    1.01  1051.8±11.28ms        ? ?/sec
bundle/bundle@threejs10x-minify-sourcemap                           1.00   1225.3±5.55ms        ? ?/sec    1.02  1248.0±17.81ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                                  1.00    503.1±6.98ms        ? ?/sec    1.02   515.4±10.61ms        ? ?/sec
remapping/remapping                                                 1.02     26.9±1.00ms        ? ?/sec    1.00     26.4±0.23ms        ? ?/sec
remapping/render-chunk-remapping                                    1.00     69.7±4.92ms        ? ?/sec    1.07     74.4±6.36ms        ? ?/sec
scan/scan@rome-ts                                                   1.00     93.3±3.10ms        ? ?/sec    1.06     99.0±2.59ms        ? ?/sec
scan/scan@threejs                                                   1.00     31.4±0.76ms        ? ?/sec    1.00     31.5±0.54ms        ? ?/sec
scan/scan@threejs10x                                                1.00    314.1±2.17ms        ? ?/sec    1.03    322.0±7.04ms        ? ?/sec

@underfin underfin force-pushed the 04-25-fix_hmr_hmr_chunk_execute_dependencies_at_first branch from 4f835df to ac1caa1 Compare April 28, 2025 02:12
Base automatically changed from 04-25-fix_hmr_hmr_chunk_execute_dependencies_at_first to main April 28, 2025 02:37
@underfin underfin force-pushed the 04-27-feat_hmr_handle_import.meta.hot branch from f126fd5 to e0fc27a Compare April 28, 2025 07:40
@netlify
Copy link

netlify bot commented Apr 28, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit e0fc27a
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/680f3108ca58f60008f76d86
😎 Deploy Preview https://deploy-preview-4339--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 site configuration.

@underfin underfin marked this pull request as ready for review April 29, 2025 09:12
@underfin underfin added this pull request to the merge queue Apr 30, 2025
Merged via the queue into main with commit 9725513 Apr 30, 2025
33 checks passed
@underfin underfin deleted the 04-27-feat_hmr_handle_import.meta.hot branch April 30, 2025 02:44
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