8000 refactor: consolidate HMR code by hai-x · Pull Request #19629 · webpack/webpack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: consolidate HMR code #19629

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 27, 2025
Merged

refactor: consolidate HMR code #19629

merged 1 commit into from
Jun 27, 2025

Conversation

hai-x
Copy link
Member
@hai-x hai-x commented Jun 25, 2025

What kind of change does this PR introduce?

Extract duplicate HMR logic into helper module.

We currently rely on the fetch API to get the HMR manifest, limiting support to browser environments, so Improve the error message for better understanding.

Did you add tests for your changes?

Existing

Does this PR introduce a breaking change?

No

What needs to be documented once your changes are merged?

Nothing

@hai-x hai-x force-pushed the esm-hmr-nitpick branch from 1d92946 to 7d652e7 Compare June 25, 2025 17:06
Copy link
codspeed-hq bot commented Jun 25, 2025

CodSpeed Performance Report

Merging #19629 will degrade performances by 72.06%

Comparing esm-hmr-nitpick (c9b52ee) with main (0e4a7ce)

Summary

⚡ 4 improvements
❌ 3 regressions
✅ 29 untouched benchmarks
⁉️ 97 dropped benchmarks

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

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark "devtool-eval", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 11.9 ms 42.5 ms -72.06%
benchmark "devtool-source-map", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 42.8 ms 62.3 ms -31.26%
benchmark "future-defaults", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 49.4 ms 61.8 ms -20.17%
benchmark "lodash", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 35 ms 11.4 ms ×3.1
benchmark "many-chunks-commonjs", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 63.1 ms 51.1 ms +23.53%
benchmark "many-chunks-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 61.9 ms 11.2 ms ×5.5
⁉️ benchmark "many-modules-esm", scenario '{"name":"mode-development","mode":"development"}' 313.2 ms N/A N/A
⁉️ benchmark "many-modules-esm", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 11.2 ms N/A N/A
⁉️ benchmark "many-modules-esm", scenario '{"name":"mode-production","mode":"production"}' 2.4 s N/A N/A
⁉️ benchmark "minimal", scenario '{"name":"mode-development","mode":"development"}' 23.8 ms N/A N/A
⁉️ benchmark "minimal", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 17.6 ms N/A N/A
⁉️ benchmark "minimal", scenario '{"name":"mode-production","mode":"production"}' 203.7 ms N/A N/A
⁉️ benchmark "react", scenario '{"name":"mode-development","mode":"development"}' 182.3 ms N/A N/A
⁉️ benchmark "react", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 35.8 ms N/A N/A
⁉️ benchmark "react", scenario '{"name":"mode-production","mode":"production"}' 862.9 ms N/A N/A
benchmark "three-long", scenario '{"name":"mode-development-rebuild","mode":"development","watch":true}' 229.7 ms 13.7 ms ×17
⁉️ md4 buffer benchmark (size: 10000) 114.3 µs N/A N/A
⁉️ md4 buffer benchmark (size: 100000) 447.9 µs N/A N/A
⁉️ md4 buffer benchmark (size: 120) 76.1 µs N/A N/A
⁉️ md4 buffer benchmark (size: 160) 76.1 µs N/A N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@alexander-akait
Copy link
Member

@hai-x Weird codecov report...

Template.getFunctionContent(
require("../hmr/JavascriptHotModuleReplacement.runtime.js")
)
.replace(/\$key\$/g, "jsonp")
Copy link
Member

Choose a reason for hiding this comment

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

Before we have jsonp, now module, is it expected change?

Copy link
Member

Choose a reason for hiding this comment

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

But it is just $key, so I think it is fine to change

/cc @xiaoxiaojx

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I think so.

@@ -407,7 +389,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
`var loadScript = ${runtimeTemplate.basicFunction(
"url, onResolve, onReject",
[
`return ${importFunctionName}(/* webpackIgnore: true */ url).then(onResolve).catch(onReject)`
Copy link
Member

Choose a reason for hiding this comment

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

Why remove? If we try to bundle already bundled webpack without it will output an error/warning

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Thank you. I will revert it.

@hai-x hai-x force-pushed the esm-hmr-nitpick branch from 043d548 to 7413e36 Compare June 26, 2025 16:47
@alexander-akait
Copy link
Member

@hai-x let's rebase and we can merge

@hai-x hai-x force-pushed the esm-hmr-nitpick branch from 7413e36 to c9b52ee Compare June 26, 2025 18:17
@hai-x hai-x changed the title refactor: consolidate HMR code and refine ESM HMR refactor: consolidate HMR code Jun 26, 2025
@alexander-akait alexander-akait merged commit 5bcd259 into main Jun 27, 2025
42 of 44 checks passed
@alexander-akait alexander-akait deleted the esm-hmr-nitpick branch June 27, 2025 15:45
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
0