hard-source-webpack-plugin
hard-source-webpack-plugin copied to clipboard
About mini-css-extract-plugin compatible
Expected Behavior
The
mini-css-extract-plugin
should be cached well when webpack is hot built。
Actual Behavior
Cause Error
Could not freeze xxx/xx.scss Cannot read property 'hash' of undefined
。
Maybe Question
The event _hardSourceFreezeModule
is not compatible when webpack is hot built scss
( use mini-css-extract-plugin
)。
With code:
if (module.request &&
(cacheable(module) || !module.built) &&
module instanceof NormalModule &&
(!frozen ||
(schema >= 4 && module.hash !== frozen.build.hash) ||
(schema < 4 &&
module.getHashDigest(extra.compilation.dependencyTemplates) !==
frozen.hash))
)
And segment:
module.hash !== frozen.build.hash
Scenes
The scss
module hash
was changed ,but the module maybe not be built (module.built===false
)。
let serialModule = serialNormalModule;
if (!module.built) {
serialModule = serialNormalModule4PreBuild;
}
And only try this code
let serialModule = serialNormalModule;
if (!module.built) {
if (module.hash) {
return null;
}
serialModule = serialNormalModule4PreBuild;
}
It's could work。
But this maybe not a foundmental problem, just a possibility。
👍 happens to me as well