mini-css-extract-plugin
mini-css-extract-plugin copied to clipboard
feat: hmr, compare old locals to invalidate if needed
This PR contains a:
- [ ] bugfix
- [x] new feature
- [ ] code refactor
- [ ] test update
- [ ] typo fix
- [ ] metadata update
Motivation / Use-Case
This allows self accept css module if locals didn't changed. If changed - propagate. Inspired by https://github.com/webpack-contrib/style-loader/blob/master/src/index.js#L231 Now new runtime is
// extracted by mini-css-extract-plugin
if(true) {
// 1612290403401
var cssReload = __webpack_require__(/*! ../node_modules/mini-css-extract-plugin/dist/hmr/hotModuleReplacement.js */ "../node_modules/mini-css-extract-plugin/dist/hmr/hotModuleReplacement.js")(module.id, {"publicPath":"","esModule":false,"locals":false});
var _locals = undefined;
var isEqualLocals = __webpack_require__(/*! ../node_modules/mini-css-extract-plugin/dist/hmr/isEqualLocals.js */ "../node_modules/mini-css-extract-plugin/dist/hmr/isEqualLocals.js");
module.hot.dispose(function(data) {
cssReload();
data.oldLocals = _locals;
});
if (!_locals || module.hot.invalidate) {
if (module.hot.invalidate &&
module.hot.data &&
module.hot.data.oldLocals &&
!isEqualLocals(module.hot.data.oldLocals, _locals)) {
module.hot.invalidate();
} else {
module.hot.accept();
}
}
}
//# sourceURL=[module]
//# sourceMappingURL=data:applicati
Breaking Changes
Additional Info
@alexander-akait could you please review? Should I fix tests first (look like all of them are code snapshots)
printed output,

@alexander-akait could you please review?
@goloveychuk Sorry for delay, apparently I missed a notification somewhere :disappointed: , do not hesitate to ping me again, do you want to finish this?