webpack-contrib / mini-css-extract-plugin

Lightweight CSS extraction plugin
MIT License
4.65k stars 390 forks source link

fix: avoid reloading all csses when hot load #1090

Closed yiminghe closed 3 months ago

yiminghe commented 4 months ago

This PR contains a:

Motivation / Use-Case

Breaking Changes

Additional Info

Fixes #692

linux-foundation-easycla[bot] commented 4 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

yiminghe commented 4 months ago

We need a test case, please add

test cases updated

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.00%. Comparing base (c7ff30d) to head (9bfc65e). Report is 7 commits behind head on master.

:exclamation: Current head 9bfc65e differs from pull request most recent head fc80832. Consider uploading reports for the commit fc80832 to get more accurate results

Files Patch % Lines
src/loader.js 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

alexander-akait commented 3 months ago

For fixing tests for OLD API just use OLD_API=1 npm run test:only

alexander-akait commented 3 months ago

Thank you for your PR

yiminghe commented 3 months ago

For fixing tests for OLD API just use OLD_API=1 npm run test:only

passed

alexander-akait commented 3 months ago

@yiminghe We have:

var cssReload = require("/home/runner/work/mini-css-extract-plugin/mini-css-extract-plugin/src/hmr/hotModuleReplacement.js")(module.id, undefined);

As you can see it is an absolute path, let's use it from here https://github.com/webpack-contrib/css-loader/blob/master/src/utils.js#L15 (maybe we already have the same util here)

yiminghe commented 3 months ago

@yiminghe We have:

var cssReload = require("/home/runner/work/mini-css-extract-plugin/mini-css-extract-plugin/src/hmr/hotModuleReplacement.js")(module.id, undefined);

As you can see it is an absolute path, let's use it from here https://github.com/webpack-contrib/css-loader/blob/master/src/utils.js#L15 (maybe we already have the same util here)

updated