Skip to content

Commit

Permalink
remove exportsConvention for css
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Apr 20, 2024
1 parent 42160d0 commit bf2571b
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 89 deletions.
4 changes: 0 additions & 4 deletions declarations/WebpackOptions.d.ts
Expand Up @@ -2888,10 +2888,6 @@ export interface CssAutoParserOptions {
* Generator options for css modules.
*/
export interface CssGeneratorOptions {
/**
* Specifies the convention of exported names.
*/
exportsConvention?: CssGeneratorExportsConvention;
/**
* Avoid generating and loading a stylesheet and only embed exports from css into output javascript files.
*/
Expand Down
4 changes: 3 additions & 1 deletion lib/config/defaults.js
Expand Up @@ -553,7 +553,6 @@ const applyCssGeneratorOptionsDefaults = (
"exportsOnly",
!targetProperties || !targetProperties.document
);
D(generatorOptions, "exportsConvention", "as-is");
};

/**
Expand Down Expand Up @@ -648,20 +647,23 @@ const applyModuleDefaults = (
"localIdentName",
"[uniqueName]-[id]-[local]"
);
D(module.generator["css/auto"], "exportsConvention", "as-is");

F(module.generator, "css/module", () => ({}));
D(
module.generator["css/module"],
"localIdentName",
"[uniqueName]-[id]-[local]"
);
D(module.generator["css/module"], "exportsConvention", "as-is");

F(module.generator, "css/global", () => ({}));
D(
module.generator["css/global"],
"localIdentName",
"[uniqueName]-[id]-[local]"
);
D(module.generator["css/global"], "exportsConvention", "as-is");
}

A(module, "defaultRules", () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/css/CssExportsGenerator.js
Expand Up @@ -31,12 +31,12 @@ const TYPES = new Set(["javascript"]);

class CssExportsGenerator extends Generator {
/**
* @param {CssGeneratorExportsConvention} convention the convention of the exports name
* @param {CssGeneratorExportsConvention | undefined} convention the convention of the exports name
* @param {CssGeneratorLocalIdentName | undefined} localIdentName css export local ident name
*/
constructor(convention, localIdentName) {
super();
/** @type {CssGeneratorExportsConvention} */
/** @type {CssGeneratorExportsConvention | undefined} */
this.convention = convention;
/** @type {CssGeneratorLocalIdentName | undefined} */
this.localIdentName = localIdentName;
Expand Down
4 changes: 2 additions & 2 deletions lib/css/CssGenerator.js
Expand Up @@ -24,12 +24,12 @@ const TYPES = new Set(["css"]);

class CssGenerator extends Generator {
/**
* @param {CssGeneratorExportsConvention} convention the convention of the exports name
* @param {CssGeneratorExportsConvention | undefined} convention the convention of the exports name
* @param {CssGeneratorLocalIdentName | undefined} localIdentName css export local ident name
*/
constructor(convention, localIdentName) {
super();
/** @type {CssGeneratorExportsConvention} */
/** @type {CssGeneratorExportsConvention | undefined} */
this.convention = convention;
/** @type {CssGeneratorLocalIdentName | undefined} */
this.localIdentName = localIdentName;
Expand Down
2 changes: 1 addition & 1 deletion lib/util/conventions.js
Expand Up @@ -9,7 +9,7 @@

/**
* @param {string} input input
* @param {CssGeneratorExportsConvention} convention convention
* @param {CssGeneratorExportsConvention | undefined} convention convention
* @returns {Set<string>} results
*/
exports.cssExportConvention = (input, convention) => {
Expand Down
2 changes: 1 addition & 1 deletion schemas/WebpackOptions.check.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions schemas/WebpackOptions.json
Expand Up @@ -432,9 +432,6 @@
"type": "object",
"additionalProperties": false,
"properties": {
"exportsConvention": {
"$ref": "#/definitions/CssGeneratorExportsConvention"
},
"exportsOnly": {
"$ref": "#/definitions/CssGeneratorExportsOnly"
}
Expand Down
2 changes: 1 addition & 1 deletion schemas/plugins/css/CssGeneratorOptions.check.js

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

11 changes: 7 additions & 4 deletions test/Defaults.unittest.js
Expand Up @@ -2255,6 +2255,7 @@ describe("snapshots", () => {
+ "css": true,
+ "futureDefaults": true,
@@ ... @@
+ },
+ Object {
+ "rules": Array [
+ Object {
Expand All @@ -2272,18 +2273,18 @@ describe("snapshots", () => {
+ Object {
+ "mimetype": "application/wasm",
+ "rules": Array [
@@ ... @@
+ Object {
+ "descriptionData": Object {
+ "type": "module",
+ },
+ "resolve": Object {
+ "fullySpecified": true,
+ },
+ },
@@ ... @@
+ ],
+ "type": "webassembly/async",
+ },
+ Object {
@@ ... @@
+ "resolve": Object {
+ "fullySpecified": true,
+ "preferRelative": true,
Expand Down Expand Up @@ -2312,16 +2313,18 @@ describe("snapshots", () => {
- "generator": Object {},
+ "generator": Object {
+ "css": Object {
+ "exportsConvention": "as-is",
+ "exportsOnly": false,
+ },
+ "css/auto": Object {
+ "exportsConvention": "as-is",
+ "localIdentName": "[uniqueName]-[id]-[local]",
+ },
+ "css/global": Object {
+ "exportsConvention": "as-is",
+ "localIdentName": "[uniqueName]-[id]-[local]",
+ },
+ "css/module": Object {
+ "exportsConvention": "as-is",
+ "localIdentName": "[uniqueName]-[id]-[local]",
+ },
+ },
Expand Down
20 changes: 0 additions & 20 deletions test/__snapshots__/Cli.basictest.js.snap
Expand Up @@ -1475,26 +1475,6 @@ Object {
"multiple": false,
"simpleType": "string",
},
"module-generator-css-exports-convention": Object {
"configs": Array [
Object {
"description": "Specifies the convention of exported names.",
"multiple": false,
"path": "module.generator.css.exportsConvention",
"type": "enum",
"values": Array [
"as-is",
"camel-case",
"camel-case-only",
"dashes",
"dashes-only",
],
},
],
"description": "Specifies the convention of exported names.",
"multiple": false,
"simpleType": "string",
},
"module-generator-css-exports-only": Object {
"configs": Array [
Object {
Expand Down
75 changes: 36 additions & 39 deletions test/__snapshots__/ConfigCacheTestCases.longtest.js.snap
Expand Up @@ -3213,16 +3213,16 @@ Array [
}
.local1,
.local2 :global .global,
.local2 .global,
.local3 {
color: green;
}
:global .global :local .local4 {
.global ._-_css-modules_style_module_css-local4 {
color: yellow;
}
.local5:global(.global).local6 {
.local5.global.local6 {
color: blue;
}
Expand Down Expand Up @@ -3290,7 +3290,7 @@ Array [
overflow: hidden;
}
:global(:global(:local(.nested1)).nested2).nested3 {
._-_css-modules_style_module_css-nested1.nested2.nested3 {
color: pink;
}
Expand Down Expand Up @@ -3339,7 +3339,7 @@ Array [
--local-color: red;
}
.globalVars :global {
.globalVars {
color: var(--global-color);
--global-color: red;
}
Expand Down Expand Up @@ -3425,7 +3425,7 @@ Array [
}
}
:GLOBAL .globalUpperCase :LOCAL .localUpperCase {
.globalUpperCase ._-_css-modules_style_module_css-localUpperCase {
color: yellow;
}
Expand All @@ -3434,7 +3434,7 @@ Array [
--LOCAL-COLOR: red;
}
.globalVarsUpperCase :GLOBAL {
.globalVarsUpperCase {
COLOR: VAR(--GLOBAR-COLOR);
--GLOBAR-COLOR: red;
}
Expand Down Expand Up @@ -3598,31 +3598,31 @@ Array [
.nested-with-local-pseudo {
color: red;
:local .local-nested {
._-_css-modules_style_module_css-local-nested {
color: red;
}
:global .global-nested {
.global-nested {
color: red;
}
:local(.local-nested) {
._-_css-modules_style_module_css-local-nested {
color: red;
}
:global(.global-nested) {
.global-nested {
color: red;
}
:local .local-nested, :global .global-nested-next {
._-_css-modules_style_module_css-local-nested, .global-nested-next {
color: red;
}
:local(.local-nested), :global(.global-nested-next) {
._-_css-modules_style_module_css-local-nested, .global-nested-next {
color: red;
}
:global .foo, .bar {
.foo, .bar {
color: red;
}
}
Expand All @@ -3643,12 +3643,12 @@ Array [
}
}
:global .global-foo {
.global-foo {
.nested-global {
color: red;
}
:local .local-in-global {
._-_css-modules_style_module_css-local-in-global {
color: blue;
}
}
Expand All @@ -3661,9 +3661,9 @@ Array [
}
}
:global .class :local .in-local-global-scope,
:global .class :local .in-local-global-scope,
:local .class-local-scope :global .in-local-global-scope {
.class ._-_css-modules_style_module_css-in-local-global-scope,
.class ._-_css-modules_style_module_css-in-local-global-scope,
._-_css-modules_style_module_css-class-local-scope .in-local-global-scope {
color: red;
}
Expand Down Expand Up @@ -3739,14 +3739,14 @@ Array [
bar: env(foo, var(--baz));
}
:global .global-foo, :local .bar {
:local .local-in-global {
.global-foo, ._-_css-modules_style_module_css-bar {
._-_css-modules_style_module_css-local-in-global {
color: blue;
}
@media screen {
:global .my-global-class-again,
:local .my-global-class-again {
.my-global-class-again,
._-_css-modules_style_module_css-my-global-class-again {
color: red;
}
}
Expand All @@ -3766,12 +3766,12 @@ Array [
}
}
:global .again-global {
.again-global {
color:red;
}
:global .again-again-global {
:global .again-again-global {
.again-again-global {
.again-again-global {
color: red;
}
}
Expand All @@ -3780,22 +3780,22 @@ Array [
--foo: red;
}
:global .again-again-global {
.again-again-global {
color: var(--foo);
:global .again-again-global {
.again-again-global {
color: var(--foo);
}
}
:global .again-again-global {
.again-again-global {
animation: slidein 3s;
:global .again-again-global, .class, :global(:global(:local(.nested1)).nested2).nested3 {
.again-again-global, .class, ._-_css-modules_style_module_css-nested1.nested2.nested3 {
animation: slidein 3s;
}
.local2 :global .global,
.local2 .global,
.local3 {
color: red;
}
Expand Down Expand Up @@ -3850,31 +3850,28 @@ Array [
}
}
:local(.class) {
._-_style_css-class {
color: red;
}
:local .class {
._-_style_css-class {
color: green;
}
:global(.class) {
.class {
color: blue;
}
:global .class {
.class {
color: white;
}
:export {
foo: bar;
}
.class {
animation: test 1s, test;
}
head{--webpack-main:\\\\.\\\\.\\\\/css-modules\\\\/style\\\\.module\\\\.css,\\\\.\\\\/style\\\\.css;}",
head{--webpack-main:local4:_-_css-modules_style_module_css-local4/nested1:_-_css-modules_style_module_css-nested1/localUpperCase:_-_css-modules_style_module_css-localUpperCase/local-nested:_-_css-modules_style_module_css-local-nested/local-in-global:_-_css-modules_style_module_css-local-in-global/in-local-global-scope:_-_css-modules_style_module_css-in-local-global-scope/class-local-scope:_-_css-modules_style_module_css-class-local-scope/bar:_-_css-modules_style_module_css-bar/my-global-class-again:_-_css-modules_style_module_css-my-global-class-again/\\\\.\\\\.\\\\/css-modules\\\\/style\\\\.module\\\\.css,class:_-_style_css-class/foo:bar/\\\\.\\\\/style\\\\.css;}",
]
`;
Expand Down

0 comments on commit bf2571b

Please sign in to comment.