Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not break @scope at-rule without params #1581

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"icss-utils": "^5.1.0",
"postcss": "^8.4.33",
"postcss-modules-extract-imports": "^3.0.0",
"postcss-modules-local-by-default": "^4.0.4",
"postcss-modules-local-by-default": "^4.0.5",
"postcss-modules-scope": "^3.1.2",
"postcss-modules-values": "^4.0.0",
"postcss-value-parser": "^4.2.0",
Expand Down
63 changes: 63 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10330,6 +10330,12 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`@scope (.kthHR5ALtmYK9QgapjA3) {
color: plum;
}
}

@scope {
:scope {
color: red;
}
}
\`, \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
Expand Down Expand Up @@ -10366,6 +10372,12 @@ Array [
color: plum;
}
}

@scope {
:scope {
color: red;
}
}
",
"",
],
Expand Down Expand Up @@ -20968,6 +20980,57 @@ Array [

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

exports[`"modules" option should work with global compose: errors 1`] = `Array []`;

exports[`"modules" option should work with global compose: module 1`] = `
"// Imports
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../../../src/runtime/noSourceMaps.js\\";
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \`.global-class {
color: red;
}

.other-global-class {
color: red;
}

.oNDnA1BRHWFMyAdR4iF1 {
color: blue;
}
\`, \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"otherClassName\\": \`oNDnA1BRHWFMyAdR4iF1 global-class other-global-class\`
};
export default ___CSS_LOADER_EXPORT___;
"
`;

exports[`"modules" option should work with global compose: result 1`] = `
Array [
Array [
"./modules/composes/global.css",
".global-class {
color: red;
}

.other-global-class {
color: red;
}

.oNDnA1BRHWFMyAdR4iF1 {
color: blue;
}
",
"",
],
]
`;

exports[`"modules" option should work with global compose: warnings 1`] = `Array []`;

exports[`"modules" option should work with the "[local]" placeholder for the "localIdentName" option: errors 1`] = `Array []`;

exports[`"modules" option should work with the "[local]" placeholder for the "localIdentName" option: module 1`] = `
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/modules/composes/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:global(.global-class) {
color: red;
}

:global(.other-global-class) {
color: red;
}

.otherClassName {
composes: global-class from global;
composes: other-global-class from global;
color: blue;
}
5 changes: 5 additions & 0 deletions test/fixtures/modules/composes/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import css from './global.css';

__export__ = css;

export default css;
6 changes: 6 additions & 0 deletions test/fixtures/modules/scope/css.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@
color: plum;
}
}

@scope {
:scope {
color: red;
}
}
16 changes: 16 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2417,4 +2417,20 @@ describe('"modules" option', () => {
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});

it("should work with global compose", async () => {
const compiler = getCompiler("./modules/composes/global.js", {
modules: true,
});
const stats = await compile(compiler);

expect(
getModuleSource("./modules/composes/global.css", stats)
).toMatchSnapshot("module");
expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot(
"result"
);
expect(getWarnings(stats)).toMatchSnapshot("warnings");
expect(getErrors(stats)).toMatchSnapshot("errors");
});
});