Skip to content

Commit 6c8ec12

Browse files
author
barak igal
authored
fix: allow consumers to access CssModule
Hey, This PR fixes a subtle breaking change happened in the last release. I had an integration that was injecting CssModule instances to the compilation, and it assumed this plugin will take care of them. After the latest release it was impossible for me to get the CssModule class since it cannot be registered twice for serialization. This PR allows others to get access to the CssModule class within same webpack running version.
1 parent 23bb03c commit 6c8ec12

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ const CODE_GENERATION_RESULT = {
1818
runtimeRequirements: new Set(),
1919
};
2020

21+
const cssModuleCache = new WeakMap();
22+
2123
class MiniCssExtractPlugin {
2224
static getCssModule(webpack) {
25+
if(cssModuleCache.has(webpack)) {
26+
return cssModuleCache.get(webpack);
27+
}
2328
class CssModule extends webpack.Module {
2429
constructor({
2530
context,
@@ -133,7 +138,9 @@ class MiniCssExtractPlugin {
133138
super.deserialize(context);
134139
}
135140
}
136-
141+
142+
cssModuleCache.set(webpack, CssModule);
143+
137144
if (
138145
webpack.util &&
139146
webpack.util.serialization &&

0 commit comments

Comments
 (0)