Skip to content

Commit 0b2a5a0

Browse files
fix(css): clean up export css local vars
2 parents eaa685e + 0258e6c commit 0b2a5a0

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

lib/css/CssLoadingRuntimeModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
226226
`module.exports = exports;`
227227
)}).bind(null, exports); ${
228228
withHmr ? "moduleIds.push(token); " : ""
229-
}token = ""; exports = {}; exportsWithId.length = 0; }`,
229+
}token = ""; exports = {}; exportsWithId.length = 0; exportsWithDashes.length = 0; }`,
230230
`else if(cc == ${cc("\\")}) { token += data[++i] }`,
231231
`else { token += data[i]; }`
232232
]),

test/__snapshots__/ConfigCacheTestCases.longtest.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,7 @@ Object {
25652565
"currentWmultiParams": "./style.module.css-local12",
25662566
"deepClassInContainer": "./style.module.css-deep-class-in-container",
25672567
"displayFlexInSupportsInMediaUpperCase": "./style.module.css-displayFlexInSupportsInMediaUpperCase",
2568+
"exportLocalVarsShouldCleanup": "false false",
25682569
"futureWmultiParams": "./style.module.css-local14",
25692570
"global": undefined,
25702571
"hasWmultiParams": "./style.module.css-local11",
@@ -2612,6 +2613,7 @@ Object {
26122613
"currentWmultiParams": "my-app-235-Hq",
26132614
"deepClassInContainer": "my-app-235-Y1",
26142615
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2616+
"exportLocalVarsShouldCleanup": "false false",
26152617
"futureWmultiParams": "my-app-235-Hb",
26162618
"global": undefined,
26172619
"hasWmultiParams": "my-app-235-AO",
@@ -2665,6 +2667,7 @@ Object {
26652667
"currentWmultiParams": "./style.module.css-local12",
26662668
"deepClassInContainer": "./style.module.css-deep-class-in-container",
26672669
"displayFlexInSupportsInMediaUpperCase": "./style.module.css-displayFlexInSupportsInMediaUpperCase",
2670+
"exportLocalVarsShouldCleanup": "false false",
26682671
"futureWmultiParams": "./style.module.css-local14",
26692672
"global": undefined,
26702673
"hasWmultiParams": "./style.module.css-local11",
@@ -2712,6 +2715,7 @@ Object {
27122715
"currentWmultiParams": "my-app-235-Hq",
27132716
"deepClassInContainer": "my-app-235-Y1",
27142717
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2718+
"exportLocalVarsShouldCleanup": "false false",
27152719
"futureWmultiParams": "my-app-235-Hb",
27162720
"global": undefined,
27172721
"hasWmultiParams": "my-app-235-AO",
@@ -2759,6 +2763,7 @@ Object {
27592763
"currentWmultiParams": "my-app-235-Hq",
27602764
"deepClassInContainer": "my-app-235-Y1",
27612765
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2766+
"exportLocalVarsShouldCleanup": "false false",
27622767
"futureWmultiParams": "my-app-235-Hb",
27632768
"global": undefined,
27642769
"hasWmultiParams": "my-app-235-AO",

test/__snapshots__/ConfigTestCases.basictest.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,7 @@ Object {
25652565
"currentWmultiParams": "./style.module.css-local12",
25662566
"deepClassInContainer": "./style.module.css-deep-class-in-container",
25672567
"displayFlexInSupportsInMediaUpperCase": "./style.module.css-displayFlexInSupportsInMediaUpperCase",
2568+
"exportLocalVarsShouldCleanup": "false false",
25682569
"futureWmultiParams": "./style.module.css-local14",
25692570
"global": undefined,
25702571
"hasWmultiParams": "./style.module.css-local11",
@@ -2612,6 +2613,7 @@ Object {
26122613
"currentWmultiParams": "my-app-235-Hq",
26132614
"deepClassInContainer": "my-app-235-Y1",
26142615
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2616+
"exportLocalVarsShouldCleanup": "false false",
26152617
"futureWmultiParams": "my-app-235-Hb",
26162618
"global": undefined,
26172619
"hasWmultiParams": "my-app-235-AO",
@@ -2665,6 +2667,7 @@ Object {
26652667
"currentWmultiParams": "./style.module.css-local12",
26662668
"deepClassInContainer": "./style.module.css-deep-class-in-container",
26672669
"displayFlexInSupportsInMediaUpperCase": "./style.module.css-displayFlexInSupportsInMediaUpperCase",
2670+
"exportLocalVarsShouldCleanup": "false false",
26682671
"futureWmultiParams": "./style.module.css-local14",
26692672
"global": undefined,
26702673
"hasWmultiParams": "./style.module.css-local11",
@@ -2712,6 +2715,7 @@ Object {
27122715
"currentWmultiParams": "my-app-235-Hq",
27132716
"deepClassInContainer": "my-app-235-Y1",
27142717
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2718+
"exportLocalVarsShouldCleanup": "false false",
27152719
"futureWmultiParams": "my-app-235-Hb",
27162720
"global": undefined,
27172721
"hasWmultiParams": "my-app-235-AO",
@@ -2759,6 +2763,7 @@ Object {
27592763
"currentWmultiParams": "my-app-235-Hq",
27602764
"deepClassInContainer": "my-app-235-Y1",
27612765
"displayFlexInSupportsInMediaUpperCase": "my-app-235-ij",
2766+
"exportLocalVarsShouldCleanup": "false false",
27622767
"futureWmultiParams": "my-app-235-Hb",
27632768
"global": undefined,
27642769
"hasWmultiParams": "my-app-235-AO",

test/configCases/css/css-modules/use-style.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { UsedClassName } from "./identifiers.module.css";
66

77
// To prevent analysis export
88
const isNotACSSModule = typeof notACssModule["c" + "lass"] === "undefined";
9+
const hasOwnProperty = (obj, p) => Object.hasOwnProperty.call(obj, p)
910

1011
export default {
1112
global: style.global,
@@ -49,5 +50,6 @@ export default {
4950
deepClassInContainer: style['deep-class-in-container'],
5051
cssModuleWithCustomFileExtension: myCssClass,
5152
notAValidCssModuleExtension: isNotACSSModule,
52-
UsedClassName
53+
UsedClassName,
54+
exportLocalVarsShouldCleanup: `${hasOwnProperty(notACssModule, 'local-color')} ${hasOwnProperty(notACssModule, "LOCAL-COLOR")}`
5355
};

0 commit comments

Comments
 (0)