Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork388
fix: avoid reloading all csses when hot load#1090
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
linux-foundation-easyclabot commentedMar 20, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
? "" | ||
: "module.hot.accept(undefined, cssReload);"; |
alexander-akaitMar 20, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why you change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
self accept is enough, it will update when dispose:https://webpack.js.org/api/hot-module-replacement/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We need a test case, please add
test cases updated |
src/loader.js Outdated
// ${Date.now()} | ||
var cssReload = require(${stringifyRequest( | ||
const cssReload = require(${stringifyRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Don't use const, it will be in the browser and break old browsers
? "" | ||
: "module.hot.accept(undefined, cssReload);"; | ||
const localsJsonString = JSON.stringify(JSON.stringify(context.locals)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why doubleJSON.stringify
? Just typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
note the interpolation:
`const localsJsonString =${localsJsonString};`
string comparation is faster
codecovbot commentedMar 27, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## master #1090 +/- ##==========================================+ Coverage 90.61% 92.00% +1.38%========================================== Files 5 5 Lines 895 900 +5 Branches 255 258 +3 ==========================================+ Hits 811 828 +17+ Misses 74 67 -7+ Partials 10 5 -5 ☔ View full report in Codecov by Sentry. |
test/cases/hmr/expected/main.js Outdated
module.hot.dispose(function(data) { | ||
data.value = localsJsonString; | ||
cssReload(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We have a special test directory for HMR, will be great to add a test case there, I know your code works fine, but we should ensure about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
what do you mean? I have added cases inside cases folder (hmr, hmr-locals)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry for delay, just put a test case herehttps://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/test/HMR.test.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry for delay, just put a test case herehttps://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/test/HMR.test.js
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Let's do small improvements and I am fine with it
For fixing tests for OLD API just use |
Thank you for your PR |
passed |
alexander-akait commentedApr 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@yiminghe We have:
As you can see it is an absolute path, let's use it from herehttps://github.com/webpack-contrib/css-loader/blob/master/src/utils.js#L15 (maybe we already have the same util here) |
updated |
Uh oh!
There was an error while loading.Please reload this page.
This PR contains a:
Motivation / Use-Case
Breaking Changes
Additional Info
Fixes#692