Skip to content

refactor: use import to load the HMR manifest to support all ESM environments #19633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

xiaoxiaojx
Copy link
Member

What kind of change does this PR introduce?
refactoring

Did you add tests for your changes?
No

Does this PR introduce a breaking change?
No

What needs to be documented once your changes are merged?
No

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to make it better to avoid breaking changes and broken very old platform

Import attributes is still young and I am afraid some legacy platform/application can be tests/used in old env where they are not supported

@alexander-akait
Copy link
Member

@xiaoxiaojx
Copy link
Member Author

@alexander-akait For this PR, I went with the simplest implementation.
If we want to support all platforms and different versions, I’m thinking of switching the file extension from .json to .mjs. That way, we avoid side effects and won’t need to pass extra config. What do you think?

Copy link

codspeed-hq bot commented Jun 26, 2025

CodSpeed Performance Report

Merging #19633 will degrade performances by 74.33%

Comparing feat/esm_hmr (af7809c) with main (10fb556)

Summary

⚡ 1 improvements
❌ 4 regressions
✅ 116 untouched benchmarks
⁉️ 12 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
⁉️ benchmark "cache-filesystem", scenario '{"name":"mode-development","mode":"development"}' 1.4 s N/A N/A
⁉️ benchmark "cache-filesystem", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 223.9 ms N/A N/A
⁉️ benchmark "cache-filesystem", scenario '{"name":"mode-production","mode":"production"}' 1.2 s N/A N/A
⁉️ benchmark "context-commonjs", scenario '{"name":"mode-development","mode":"development"}' 156.2 ms N/A N/A
⁉️ benchmark "context-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 38.2 ms N/A N/A
⁉️ benchmark "context-commonjs", scenario '{"name":"mode-production","mode":"production"}' 747.2 ms N/A N/A
⁉️ benchmark "context-esm", scenario '{"name":"mode-development","mode":"development"}' 188.1 ms N/A N/A
⁉️ benchmark "context-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 60.3 ms N/A N/A
⁉️ benchmark "context-esm", scenario '{"name":"mode-production","mode":"production"}' 3.6 s N/A N/A
benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 37.4 ms 44.9 ms -16.71%
benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 34.9 ms 11.4 ms ×3.1
benchmark "many-chunks-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 53.9 ms 62.3 ms -13.48%
benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 11.2 ms 43.6 ms -74.33%
benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 10.8 ms 34.9 ms -68.94%
⁉️ benchmark "three-long", scenario '{"name":"mode-development","mode":"development"}' 5.4 s N/A N/A
⁉️ benchmark "three-long", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 214 ms N/A N/A
⁉️ benchmark "three-long", scenario '{"name":"mode-production","mode":"production"}' 5.3 s N/A N/A

@alexander-akait
Copy link
Member

@xiaoxiaojx I am fine with it too, yeah, it is more simple solution

@xiaoxiaojx xiaoxiaojx changed the title refactor: reimplement hmrDownloadManifest in ESM to support more plat… refactor: use import to load the HMR manifest to support all ESM environments Jun 26, 2025
@alexander-akait
Copy link
Member

@xiaoxiaojx sometimes we have weird problems with benchmark:

/** @type {Generator} */ (this.generator).getSize(this, type)

we will need to look (and also make benchmark more stable), not related to this PR, hope we will resolve it soon

@alexander-akait alexander-akait merged commit 0e4a7ce into main Jun 26, 2025
40 of 43 checks passed
@alexander-akait alexander-akait deleted the feat/esm_hmr branch June 26, 2025 18:11
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