Skip to content

Commit aab1da9

Browse files
fix: css modules bugs
1 parent 22c48fb commit aab1da9

29 files changed

+11280
-1798
lines changed

.changeset/late-geckos-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Fixed bugs for `css/global` type.

.changeset/poor-hotels-sort.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": patch
33
---
44

5-
The speed of identifier parsing has been improved
5+
The speed of identifier parsing has been improved.

lib/css/CssGenerator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,15 @@ class CssGenerator extends Generator {
372372
if (!usedName) {
373373
continue;
374374
}
375-
let identifier = Template.toIdentifier(usedName);
376375

376+
let identifier = Template.toIdentifier(usedName);
377377
if (RESERVED_IDENTIFIER.has(identifier)) {
378378
identifier = `_${identifier}`;
379379
}
380-
const i = 0;
380+
let i = 0;
381381
while (usedIdentifiers.has(identifier)) {
382382
identifier = Template.toIdentifier(name + i);
383+
i += 1;
383384
}
384385
usedIdentifiers.add(identifier);
385386
generateContext.concatenationScope.registerExport(name, identifier);

lib/css/CssModulesPlugin.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,10 @@ const {
2626
} = require("../ModuleTypeConstants");
2727
const NormalModule = require("../NormalModule");
2828
const RuntimeGlobals = require("../RuntimeGlobals");
29-
const SelfModuleFactory = require("../SelfModuleFactory");
3029
const Template = require("../Template");
3130
const WebpackError = require("../WebpackError");
3231
const CssIcssExportDependency = require("../dependencies/CssIcssExportDependency");
33-
const CssIcssFromIdentifierDependency = require("../dependencies/CssIcssFromIdentifierDependency");
34-
const CssIcssGlobalIdentifierDependency = require("../dependencies/CssIcssGlobalIdentifierDependency");
3532
const CssIcssImportDependency = require("../dependencies/CssIcssImportDependency");
36-
const CssIcssLocalIdentifierDependency = require("../dependencies/CssIcssLocalIdentifierDependency");
37-
const CssIcssSelfLocalIdentifierDependency = require("../dependencies/CssIcssSelfLocalIdentifierDependency");
3833
const CssIcssSymbolDependency = require("../dependencies/CssIcssSymbolDependency");
3934
const CssImportDependency = require("../dependencies/CssImportDependency");
4035
const CssUrlDependency = require("../dependencies/CssUrlDependency");
@@ -220,7 +215,6 @@ class CssModulesPlugin {
220215
PLUGIN_NAME,
221216
(compilation, { normalModuleFactory }) => {
222217
const hooks = CssModulesPlugin.getCompilationHooks(compilation);
223-
const selfFactory = new SelfModuleFactory(compilation.moduleGraph);
224218
compilation.dependencyFactories.set(
225219
CssImportDependency,
226220
normalModuleFactory
@@ -237,18 +231,6 @@ class CssModulesPlugin {
237231
CssUrlDependency,
238232
new CssUrlDependency.Template()
239233
);
240-
compilation.dependencyTemplates.set(
241-
CssIcssLocalIdentifierDependency,
242-
new CssIcssLocalIdentifierDependency.Template()
243-
);
244-
compilation.dependencyFactories.set(
245-
CssIcssSelfLocalIdentifierDependency,
246-
selfFactory
247-
);
248-
compilation.dependencyTemplates.set(
249-
CssIcssSelfLocalIdentifierDependency,
250-
new CssIcssSelfLocalIdentifierDependency.Template()
251-
);
252234
compilation.dependencyFactories.set(
253235
CssIcssImportDependency,
254236
normalModuleFactory
@@ -257,22 +239,6 @@ class CssModulesPlugin {
257239
CssIcssImportDependency,
258240
new CssIcssImportDependency.Template()
259241
);
260-
compilation.dependencyFactories.set(
261-
CssIcssFromIdentifierDependency,
262-
normalModuleFactory
263-
);
264-
compilation.dependencyTemplates.set(
265-
CssIcssFromIdentifierDependency,
266-
new CssIcssFromIdentifierDependency.Template()
267-
);
268-
compilation.dependencyFactories.set(
269-
CssIcssGlobalIdentifierDependency,
270-
normalModuleFactory
271-
);
272-
compilation.dependencyTemplates.set(
273-
CssIcssGlobalIdentifierDependency,
274-
new CssIcssGlobalIdentifierDependency.Template()
275-
);
276242
compilation.dependencyTemplates.set(
277243
CssIcssExportDependency,
278244
new CssIcssExportDependency.Template()

0 commit comments

Comments
 (0)