refactor: move Module.hot to NormalModule#21028
Conversation
🦋 Changeset detectedLatest commit: 03222ee The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This PR is packaged and the instant preview is available (03222ee). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@03222ee
yarn add -D webpack@https://pkg.pr.new/webpack@03222ee
pnpm add -D webpack@https://pkg.pr.new/webpack@03222ee |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21028 +/- ##
==========================================
+ Coverage 91.65% 91.66% +0.01%
==========================================
Files 573 573
Lines 59817 59817
Branches 16153 16154 +1
==========================================
+ Hits 54824 54830 +6
+ Misses 4993 4987 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR refactors webpack’s internal “HMR-enabled module” flag by moving the hot boolean from the base Module class to NormalModule (and subclasses like CssModule), since it’s only written via NormalModuleFactory.hooks.module and only read by NormalModule/CSS code paths.
Changes:
- Move
hotinitialization and (de)serialization fromlib/Module.jstolib/NormalModule.js. - Guard
HotModuleReplacementPlugin’snormalModuleFactory.hooks.modulesetter withmodule instanceof NormalModule. - Update generated typings and add a changeset documenting the move.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
types.d.ts |
Moves hot typing from Module to NormalModule in the public .d.ts surface. |
lib/NormalModule.js |
Adds hot initialization and includes hot in NormalModule serialization/deserialization. |
lib/Module.js |
Removes hot property initialization and serialization from the base Module class. |
lib/HotModuleReplacementPlugin.js |
Only marks modules as hot when they’re instanceof NormalModule. |
.changeset/move-hot-flag-to-normal-module.md |
Documents the refactor as a patch changeset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "webpack": patch | |||
The flag is only written by HMR through `NormalModuleFactory.hooks.module` and only read by `NormalModule`/`CssModule`/`CssGenerator`, so move it to `NormalModule` and guard the HMR setter with an instanceof check. Other base-`Module` subclasses (ContextModule, ExternalModule, RawModule, RuntimeModule, ConsumeSharedModule) no longer carry the property.
023965e to
03222ee
Compare
Types CoverageCoverage after merging claude/todo-resolve-non-lazy-BZqwN into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The flag is only written by HMR through
NormalModuleFactory.hooks.moduleand only read by
NormalModule/CssModule/CssGenerator, so move it toNormalModuleand guard the HMR setter with an instanceof check. Otherbase-
Modulesubclasses (ContextModule, ExternalModule, RawModule,RuntimeModule, ConsumeSharedModule) no longer carry the property.