Skip to content

Commit e022e3b

Browse files
fix: do not break @scope at-rule without params (#1581)
1 parent 6274480 commit e022e3b

File tree

7 files changed

+111
-8
lines changed

7 files changed

+111
-8
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"icss-utils": "^5.1.0",
5959
"postcss": "^8.4.33",
6060
"postcss-modules-extract-imports": "^3.0.0",
61-
"postcss-modules-local-by-default": "^4.0.4",
61+
"postcss-modules-local-by-default": "^4.0.5",
6262
"postcss-modules-scope": "^3.1.2",
6363
"postcss-modules-values": "^4.0.0",
6464
"postcss-value-parser": "^4.2.0",

test/__snapshots__/modules-option.test.js.snap

+63
Original file line numberDiff line numberDiff line change
@@ -10330,6 +10330,12 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`@scope (.kthHR5ALtmYK9QgapjA3) {
1033010330
color: plum;
1033110331
}
1033210332
}
10333+
10334+
@scope {
10335+
:scope {
10336+
color: red;
10337+
}
10338+
}
1033310339
\`, \\"\\"]);
1033410340
// Exports
1033510341
___CSS_LOADER_EXPORT___.locals = {
@@ -10366,6 +10372,12 @@ Array [
1036610372
color: plum;
1036710373
}
1036810374
}
10375+
10376+
@scope {
10377+
:scope {
10378+
color: red;
10379+
}
10380+
}
1036910381
",
1037010382
"",
1037110383
],
@@ -20968,6 +20980,57 @@ Array [
2096820980

2096920981
exports[`"modules" option should work with composes when the "namedExport" is enabled and "exportLocalsConvention" options has "dashesOnly" value: warnings 1`] = `Array []`;
2097020982

20983+
exports[`"modules" option should work with global compose: errors 1`] = `Array []`;
20984+
20985+
exports[`"modules" option should work with global compose: module 1`] = `
20986+
"// Imports
20987+
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../../../src/runtime/noSourceMaps.js\\";
20988+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
20989+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
20990+
// Module
20991+
___CSS_LOADER_EXPORT___.push([module.id, \`.global-class {
20992+
color: red;
20993+
}
20994+
20995+
.other-global-class {
20996+
color: red;
20997+
}
20998+
20999+
.oNDnA1BRHWFMyAdR4iF1 {
21000+
color: blue;
21001+
}
21002+
\`, \\"\\"]);
21003+
// Exports
21004+
___CSS_LOADER_EXPORT___.locals = {
21005+
\\"otherClassName\\": \`oNDnA1BRHWFMyAdR4iF1 global-class other-global-class\`
21006+
};
21007+
export default ___CSS_LOADER_EXPORT___;
21008+
"
21009+
`;
21010+
21011+
exports[`"modules" option should work with global compose: result 1`] = `
21012+
Array [
21013+
Array [
21014+
"./modules/composes/global.css",
21015+
".global-class {
21016+
color: red;
21017+
}
21018+
21019+
.other-global-class {
21020+
color: red;
21021+
}
21022+
21023+
.oNDnA1BRHWFMyAdR4iF1 {
21024+
color: blue;
21025+
}
21026+
",
21027+
"",
21028+
],
21029+
]
21030+
`;
21031+
21032+
exports[`"modules" option should work with global compose: warnings 1`] = `Array []`;
21033+
2097121034
exports[`"modules" option should work with the "[local]" placeholder for the "localIdentName" option: errors 1`] = `Array []`;
2097221035

2097321036
exports[`"modules" option should work with the "[local]" placeholder for the "localIdentName" option: module 1`] = `
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:global(.global-class) {
2+
color: red;
3+
}
4+
5+
:global(.other-global-class) {
6+
color: red;
7+
}
8+
9+
.otherClassName {
10+
composes: global-class from global;
11+
composes: other-global-class from global;
12+
color: blue;
13+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import css from './global.css';
2+
3+
__export__ = css;
4+
5+
export default css;

test/fixtures/modules/scope/css.css

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@
1818
color: plum;
1919
}
2020
}
21+
22+
@scope {
23+
:scope {
24+
color: red;
25+
}
26+
}

test/modules-option.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -2417,4 +2417,20 @@ describe('"modules" option', () => {
24172417
expect(getWarnings(stats)).toMatchSnapshot("warnings");
24182418
expect(getErrors(stats)).toMatchSnapshot("errors");
24192419
});
2420+
2421+
it("should work with global compose", async () => {
2422+
const compiler = getCompiler("./modules/composes/global.js", {
2423+
modules: true,
2424+
});
2425+
const stats = await compile(compiler);
2426+
2427+
expect(
2428+
getModuleSource("./modules/composes/global.css", stats)
2429+
).toMatchSnapshot("module");
2430+
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
2431+
"result"
2432+
);
2433+
expect(getWarnings(stats)).toMatchSnapshot("warnings");
2434+
expect(getErrors(stats)).toMatchSnapshot("errors");
2435+
});
24202436
});

0 commit comments

Comments
 (0)