From d70117d901686855d476eee02be6be3d2016d2d3 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Sat, 3 Feb 2024 14:10:16 +0530 Subject: [PATCH 1/8] chore: update dependency-review-action to the latest version (#1570) --- .github/workflows/dependency-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 2167bb12..8caf799d 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -11,4 +11,4 @@ jobs: - name: "Checkout Repository" uses: actions/checkout@v4 - name: "Dependency Review" - uses: actions/dependency-review-action@v3 + uses: actions/dependency-review-action@v4 From 53b3096f6fbbaf9c4cbca4f73e599da29d336826 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Tue, 27 Feb 2024 16:00:01 +0300 Subject: [PATCH 2/8] test: case for pure and nesting (#1573) --- .../__snapshots__/modules-option.test.js.snap | 57 ++++++++++++++++++- test/fixtures/modules/pure/pure.css | 8 +++ 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index 15d944d7..eba3389d 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -7930,6 +7930,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} \`, \\"\\"]); // Exports ___CSS_LOADER_EXPORT___.locals = { @@ -7947,7 +7955,8 @@ ___CSS_LOADER_EXPORT___.locals = { \\"bar-2\\": \`XbSw2R5rWm8FCPx8AUjP\`, \\"baz-3\\": \`owPaXiJkt4EitYBDn5Yh\`, \\"baz\\": \`CP7zuaZH99lZJVmJwA3g\`, - \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\` + \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\`, + \\"test\\": \`nnjcLLGI3W9kePCpF3rz\` }; export default ___CSS_LOADER_EXPORT___; " @@ -7996,6 +8005,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} ", "", ], @@ -8051,6 +8068,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} \`, \\"\\"]); // Exports ___CSS_LOADER_EXPORT___.locals = { @@ -8068,7 +8093,8 @@ ___CSS_LOADER_EXPORT___.locals = { \\"bar-2\\": \`XbSw2R5rWm8FCPx8AUjP\`, \\"baz-3\\": \`owPaXiJkt4EitYBDn5Yh\`, \\"baz\\": \`CP7zuaZH99lZJVmJwA3g\`, - \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\` + \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\`, + \\"test\\": \`nnjcLLGI3W9kePCpF3rz\` }; export default ___CSS_LOADER_EXPORT___; " @@ -8117,6 +8143,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} ", "", ], @@ -10717,6 +10751,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} \`, \\"\\"]); // Exports ___CSS_LOADER_EXPORT___.locals = { @@ -10734,7 +10776,8 @@ ___CSS_LOADER_EXPORT___.locals = { \\"bar-2\\": \`XbSw2R5rWm8FCPx8AUjP\`, \\"baz-3\\": \`owPaXiJkt4EitYBDn5Yh\`, \\"baz\\": \`CP7zuaZH99lZJVmJwA3g\`, - \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\` + \\"bar-4\\": \`vvLsn8M1D1up5NfSbIYh\`, + \\"test\\": \`nnjcLLGI3W9kePCpF3rz\` }; export default ___CSS_LOADER_EXPORT___; " @@ -10783,6 +10826,14 @@ h1 #CEBxO1NI6KSE4aIOEe8g { .owPaXiJkt4EitYBDn5Yh .CP7zuaZH99lZJVmJwA3g .vvLsn8M1D1up5NfSbIYh { color: black; } + +.nnjcLLGI3W9kePCpF3rz { + color: red; + + & > span { + color: green; + } +} ", "", ], diff --git a/test/fixtures/modules/pure/pure.css b/test/fixtures/modules/pure/pure.css index addb88d0..71693e98 100644 --- a/test/fixtures/modules/pure/pure.css +++ b/test/fixtures/modules/pure/pure.css @@ -37,3 +37,11 @@ h1 #foo-6 { .baz-3 :local(.baz) .bar-4 { color: black; } + +.test { + color: red; + + & > span { + color: green; + } +} From f5be49cb7f50620ec72c590de6f8851135b130c4 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Wed, 28 Feb 2024 17:03:18 +0530 Subject: [PATCH 3/8] ci: fix commitlint check (#1574) --- .github/workflows/nodejs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a9b6c315..9d2cdd0e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -51,8 +51,9 @@ jobs: - name: Security audit run: npm run security - - name: Check commit message - uses: wagoid/commitlint-github-action@v5 + - name: Validate PR commits with commitlint + if: github.event_name == 'pull_request' + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose test: name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} From 24e114a909421ed2f817d4b5f35f14fd67a80990 Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Sat, 2 Mar 2024 18:41:09 +0530 Subject: [PATCH 4/8] chore: update codecov-action to v4 (#1575) --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9d2cdd0e..bb1d7a24 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -94,6 +94,6 @@ jobs: run: npm run test:coverage -- --ci - name: Submit coverage data to codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} From 62744802b34cba22f422e9614957a9990fe0b919 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:41:50 +0300 Subject: [PATCH 5/8] test: for @scope (#1580) --- package-lock.json | 23 +++++++++++++------ package.json | 2 +- .../__snapshots__/modules-option.test.js.snap | 4 +++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index dff4370e..b56cb1e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "postcss": "^8.4.33", "postcss-modules-extract-imports": "^3.0.0", "postcss-modules-local-by-default": "^4.0.4", - "postcss-modules-scope": "^3.1.1", + "postcss-modules-scope": "^3.1.2", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", "semver": "^7.5.4" @@ -65,7 +65,16 @@ "url": "https://opencollective.com/webpack" }, "peerDependencies": { + "@rspack/core": "0.x || 1.x", "webpack": "^5.0.0" + }, + "peerDependenciesMeta": { + "@rspack/core": { + "optional": true + }, + "webpack": { + "optional": true + } } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -13033,9 +13042,9 @@ } }, "node_modules/postcss-modules-scope": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.1.tgz", - "integrity": "sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.2.tgz", + "integrity": "sha512-hHTYdjVmywC2TAmz134e9M4WZ6i9bh9OoHD8l2qVqc/fXxti1+4UDfZ+Pw/WCdkNIi811eJiTQ+RsfTFEuAjXw==", "dependencies": { "postcss-selector-parser": "^6.0.4" }, @@ -25519,9 +25528,9 @@ } }, "postcss-modules-scope": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.1.tgz", - "integrity": "sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.2.tgz", + "integrity": "sha512-hHTYdjVmywC2TAmz134e9M4WZ6i9bh9OoHD8l2qVqc/fXxti1+4UDfZ+Pw/WCdkNIi811eJiTQ+RsfTFEuAjXw==", "requires": { "postcss-selector-parser": "^6.0.4" } diff --git a/package.json b/package.json index a7f78ef4..f78437ff 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "postcss": "^8.4.33", "postcss-modules-extract-imports": "^3.0.0", "postcss-modules-local-by-default": "^4.0.4", - "postcss-modules-scope": "^3.1.1", + "postcss-modules-scope": "^3.1.2", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", "semver": "^7.5.4" diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index eba3389d..cdb00fe4 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -10334,7 +10334,9 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`@scope (.kthHR5ALtmYK9QgapjA3) { // Exports ___CSS_LOADER_EXPORT___.locals = { \\"class-a\\": \`tHELZHxFZl5YuwVt1kmN\`, - \\"class-b\\": \`yv3SIfJTNkZjzBV3Fc0c\` + \\"class-b\\": \`yv3SIfJTNkZjzBV3Fc0c\`, + \\"light-scheme\\": \`kthHR5ALtmYK9QgapjA3\`, + \\"dark-scheme\\": \`kodeNqRFoMkWN6SDcuTu\` }; export default ___CSS_LOADER_EXPORT___; " From e022e3bb405472ac7d51ff1114783fc2811dfe04 Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:16:30 +0300 Subject: [PATCH 6/8] fix: do not break `@scope` at-rule without params (#1581) --- package-lock.json | 14 ++--- package.json | 2 +- .../__snapshots__/modules-option.test.js.snap | 63 +++++++++++++++++++ test/fixtures/modules/composes/global.css | 13 ++++ test/fixtures/modules/composes/global.js | 5 ++ test/fixtures/modules/scope/css.css | 6 ++ test/modules-option.test.js | 16 +++++ 7 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/modules/composes/global.css create mode 100644 test/fixtures/modules/composes/global.js diff --git a/package-lock.json b/package-lock.json index b56cb1e6..672d6c2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,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", @@ -13026,9 +13026,9 @@ } }, "node_modules/postcss-modules-local-by-default": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.4.tgz", - "integrity": "sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.5.tgz", + "integrity": "sha512-6MieY7sIfTK0hYfafw1OMEG+2bg8Q1ocHCpoWLqOKj3JXlKu4G7btkmM/B7lFubYkYWmRSPLZi5chid63ZaZYw==", "dependencies": { "icss-utils": "^5.0.0", "postcss-selector-parser": "^6.0.2", @@ -25518,9 +25518,9 @@ "requires": {} }, "postcss-modules-local-by-default": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.4.tgz", - "integrity": "sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.5.tgz", + "integrity": "sha512-6MieY7sIfTK0hYfafw1OMEG+2bg8Q1ocHCpoWLqOKj3JXlKu4G7btkmM/B7lFubYkYWmRSPLZi5chid63ZaZYw==", "requires": { "icss-utils": "^5.0.0", "postcss-selector-parser": "^6.0.2", diff --git a/package.json b/package.json index f78437ff..bd9674d8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index cdb00fe4..ae599c55 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -10330,6 +10330,12 @@ ___CSS_LOADER_EXPORT___.push([module.id, \`@scope (.kthHR5ALtmYK9QgapjA3) { color: plum; } } + +@scope { + :scope { + color: red; + } +} \`, \\"\\"]); // Exports ___CSS_LOADER_EXPORT___.locals = { @@ -10366,6 +10372,12 @@ Array [ color: plum; } } + +@scope { + :scope { + color: red; + } +} ", "", ], @@ -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`] = ` diff --git a/test/fixtures/modules/composes/global.css b/test/fixtures/modules/composes/global.css new file mode 100644 index 00000000..5b4cfcd1 --- /dev/null +++ b/test/fixtures/modules/composes/global.css @@ -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; +} diff --git a/test/fixtures/modules/composes/global.js b/test/fixtures/modules/composes/global.js new file mode 100644 index 00000000..e2e84944 --- /dev/null +++ b/test/fixtures/modules/composes/global.js @@ -0,0 +1,5 @@ +import css from './global.css'; + +__export__ = css; + +export default css; diff --git a/test/fixtures/modules/scope/css.css b/test/fixtures/modules/scope/css.css index e30abe49..96862906 100644 --- a/test/fixtures/modules/scope/css.css +++ b/test/fixtures/modules/scope/css.css @@ -18,3 +18,9 @@ color: plum; } } + +@scope { + :scope { + color: red; + } +} diff --git a/test/modules-option.test.js b/test/modules-option.test.js index ed4b9329..9529312b 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -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"); + }); }); From bbca61411dc5f82964653a6d1aa27854519b743d Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:38:34 +0300 Subject: [PATCH 7/8] feat: supports multiple composes (#1582) --- README.md | 9 ++ package-lock.json | 28 ++--- package.json | 4 +- .../__snapshots__/modules-option.test.js.snap | 117 ++++++++++++++++++ test/fixtures/modules/composes/alias-1.css | 7 ++ test/fixtures/modules/composes/multiple.css | 38 ++++++ test/fixtures/modules/composes/multiple.js | 5 + test/modules-option.test.js | 16 +++ 8 files changed, 208 insertions(+), 16 deletions(-) create mode 100644 test/fixtures/modules/composes/alias-1.css create mode 100644 test/fixtures/modules/composes/multiple.css create mode 100644 test/fixtures/modules/composes/multiple.js diff --git a/README.md b/README.md index 57c86b33..57d213dd 100644 --- a/README.md +++ b/README.md @@ -487,6 +487,15 @@ To import a local classname from another module. To import from multiple modules use multiple `composes:` rules. +```css +:local(.className) { + composes: edit highlight from "./edit.css", button from "module/button.css", classFromThisModule; + background: red; +} +``` + +or + ```css :local(.className) { composes: edit highlight from "./edit.css"; diff --git a/package-lock.json b/package-lock.json index 672d6c2b..3786e3f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,9 @@ "dependencies": { "icss-utils": "^5.1.0", "postcss": "^8.4.33", - "postcss-modules-extract-imports": "^3.0.0", + "postcss-modules-extract-imports": "^3.1.0", "postcss-modules-local-by-default": "^4.0.5", - "postcss-modules-scope": "^3.1.2", + "postcss-modules-scope": "^3.2.0", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", "semver": "^7.5.4" @@ -13015,9 +13015,9 @@ } }, "node_modules/postcss-modules-extract-imports": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", - "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.1.0.tgz", + "integrity": "sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==", "engines": { "node": "^10 || ^12 || >= 14" }, @@ -13042,9 +13042,9 @@ } }, "node_modules/postcss-modules-scope": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.2.tgz", - "integrity": "sha512-hHTYdjVmywC2TAmz134e9M4WZ6i9bh9OoHD8l2qVqc/fXxti1+4UDfZ+Pw/WCdkNIi811eJiTQ+RsfTFEuAjXw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.2.0.tgz", + "integrity": "sha512-oq+g1ssrsZOsx9M96c5w8laRmvEu9C3adDSjI8oTcbfkrTE8hx/zfyobUoWIxaKPO8bt6S62kxpw5GqypEw1QQ==", "dependencies": { "postcss-selector-parser": "^6.0.4" }, @@ -25512,9 +25512,9 @@ "requires": {} }, "postcss-modules-extract-imports": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", - "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.1.0.tgz", + "integrity": "sha512-k3kNe0aNFQDAZGbin48pL2VNidTF0w4/eASDsxlyspobzU3wZQLOGj7L9gfRe0Jo9/4uud09DsjFNH7winGv8Q==", "requires": {} }, "postcss-modules-local-by-default": { @@ -25528,9 +25528,9 @@ } }, "postcss-modules-scope": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.1.2.tgz", - "integrity": "sha512-hHTYdjVmywC2TAmz134e9M4WZ6i9bh9OoHD8l2qVqc/fXxti1+4UDfZ+Pw/WCdkNIi811eJiTQ+RsfTFEuAjXw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/postcss-modules-scope/-/postcss-modules-scope-3.2.0.tgz", + "integrity": "sha512-oq+g1ssrsZOsx9M96c5w8laRmvEu9C3adDSjI8oTcbfkrTE8hx/zfyobUoWIxaKPO8bt6S62kxpw5GqypEw1QQ==", "requires": { "postcss-selector-parser": "^6.0.4" } diff --git a/package.json b/package.json index bd9674d8..fd71a2b5 100644 --- a/package.json +++ b/package.json @@ -57,9 +57,9 @@ "dependencies": { "icss-utils": "^5.1.0", "postcss": "^8.4.33", - "postcss-modules-extract-imports": "^3.0.0", + "postcss-modules-extract-imports": "^3.1.0", "postcss-modules-local-by-default": "^4.0.5", - "postcss-modules-scope": "^3.1.2", + "postcss-modules-scope": "^3.2.0", "postcss-modules-values": "^4.0.0", "postcss-value-parser": "^4.2.0", "semver": "^7.5.4" diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index ae599c55..97cc528f 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -21031,6 +21031,123 @@ Array [ exports[`"modules" option should work with global compose: warnings 1`] = `Array []`; +exports[`"modules" option should work with multiple compose: errors 1`] = `Array []`; + +exports[`"modules" option should work with multiple 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\\"; +import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../src/index.js??ruleSet[1].rules[0].use[0]!./alias.css\\"; +import ___CSS_LOADER_ICSS_IMPORT_1___ from \\"-!../../../../src/index.js??ruleSet[1].rules[0].use[0]!./alias-1.css\\"; +var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true); +___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_1___, \\"\\", true); +// Module +___CSS_LOADER_EXPORT___.push([module.id, \`.RsClSIMkfTMmUvwYT4aD { + color: red; +} + +.OdpZEdUc2oHF96Xqdoba { + color: blue; +} + +.A3lCTIjOyIaMw91SUTt_ { + color: blue; +} + +.global-class { + padding: 10px; +} + +.global-class-1 { + padding: 10px; +} + +.global-class-2 { + padding: 10px; +} + +.BwiLdQraIwYyRAA53QEQ { + color: gainsboro; +} + +.DemABT8Zz2xVnnu848uO { +} +\`, \\"\\"]); +// Exports +___CSS_LOADER_EXPORT___.locals = { + \\"other-class\\": \`RsClSIMkfTMmUvwYT4aD\`, + \\"class-1\\": \`OdpZEdUc2oHF96Xqdoba\`, + \\"class-2\\": \`A3lCTIjOyIaMw91SUTt_\`, + \\"class\\": \`BwiLdQraIwYyRAA53QEQ RsClSIMkfTMmUvwYT4aD OdpZEdUc2oHF96Xqdoba A3lCTIjOyIaMw91SUTt_ \${___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"imported-alias\\"]} \${___CSS_LOADER_ICSS_IMPORT_1___.locals[\\"imported-alias-2\\"]} \${___CSS_LOADER_ICSS_IMPORT_1___.locals[\\"imported-alias-3\\"]} global-class global-class-1 global-class-2\`, + \\"class-other\\": \`DemABT8Zz2xVnnu848uO RsClSIMkfTMmUvwYT4aD OdpZEdUc2oHF96Xqdoba\` +}; +export default ___CSS_LOADER_EXPORT___; +" +`; + +exports[`"modules" option should work with multiple compose: result 1`] = ` +Array [ + Array [ + "../../src/index.js??ruleSet[1].rules[0].use[0]!./modules/composes/alias.css", + ".dnhKs1AYKq4KodZdfzcx { + display: table; +} +", + "", + ], + Array [ + "../../src/index.js??ruleSet[1].rules[0].use[0]!./modules/composes/alias-1.css", + ".Lg5UPByIZH1XWiASCk_q { + background: red; +} + +.QllkotlwlKJ4pFhiIzqP { + background: red; +} +", + "", + ], + Array [ + "./modules/composes/multiple.css", + ".RsClSIMkfTMmUvwYT4aD { + color: red; +} + +.OdpZEdUc2oHF96Xqdoba { + color: blue; +} + +.A3lCTIjOyIaMw91SUTt_ { + color: blue; +} + +.global-class { + padding: 10px; +} + +.global-class-1 { + padding: 10px; +} + +.global-class-2 { + padding: 10px; +} + +.BwiLdQraIwYyRAA53QEQ { + color: gainsboro; +} + +.DemABT8Zz2xVnnu848uO { +} +", + "", + ], +] +`; + +exports[`"modules" option should work with multiple 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`] = ` diff --git a/test/fixtures/modules/composes/alias-1.css b/test/fixtures/modules/composes/alias-1.css new file mode 100644 index 00000000..80cba29a --- /dev/null +++ b/test/fixtures/modules/composes/alias-1.css @@ -0,0 +1,7 @@ +.imported-alias-2 { + background: red; +} + +.imported-alias-3 { + background: red; +} diff --git a/test/fixtures/modules/composes/multiple.css b/test/fixtures/modules/composes/multiple.css new file mode 100644 index 00000000..3520c43e --- /dev/null +++ b/test/fixtures/modules/composes/multiple.css @@ -0,0 +1,38 @@ +.other-class { + color: red; +} + +.class-1 { + color: blue; +} + +.class-2 { + color: blue; +} + +:global(.global-class) { + padding: 10px; +} + +:global(.global-class-1) { + padding: 10px; +} + +:global(.global-class-2) { + padding: 10px; +} + +.class { + composes: + other-class, + class-1 class-2, + imported-alias from './alias.css', + imported-alias-2 imported-alias-3 from './alias-1.css', + global-class from global, + global-class-1 global-class-2 from global; + color: gainsboro; +} + +.class-other { + composes: other-class class-1; +} diff --git a/test/fixtures/modules/composes/multiple.js b/test/fixtures/modules/composes/multiple.js new file mode 100644 index 00000000..63f5814e --- /dev/null +++ b/test/fixtures/modules/composes/multiple.js @@ -0,0 +1,5 @@ +import css from './multiple.css'; + +__export__ = css; + +export default css; diff --git a/test/modules-option.test.js b/test/modules-option.test.js index 9529312b..06b7d708 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -2433,4 +2433,20 @@ describe('"modules" option', () => { expect(getWarnings(stats)).toMatchSnapshot("warnings"); expect(getErrors(stats)).toMatchSnapshot("errors"); }); + + it("should work with multiple compose", async () => { + const compiler = getCompiler("./modules/composes/multiple.js", { + modules: true, + }); + const stats = await compile(compiler); + + expect( + getModuleSource("./modules/composes/multiple.css", stats) + ).toMatchSnapshot("module"); + expect(getExecutedCode("main.bundle.js", compiler, stats)).toMatchSnapshot( + "result" + ); + expect(getWarnings(stats)).toMatchSnapshot("warnings"); + expect(getErrors(stats)).toMatchSnapshot("errors"); + }); }); From 95cf5c58078e0af50f352347a76d9b81749df78e Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Wed, 3 Apr 2024 19:18:33 +0300 Subject: [PATCH 8/8] chore(release): 6.11.0 --- CHANGELOG.md | 12 ++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a9f3c0b..c1a53ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [6.11.0](https://github.com/webpack-contrib/css-loader/compare/v6.10.0...v6.11.0) (2024-04-03) + + +### Features + +* supports multiple composes ([#1582](https://github.com/webpack-contrib/css-loader/issues/1582)) ([bbca614](https://github.com/webpack-contrib/css-loader/commit/bbca61411dc5f82964653a6d1aa27854519b743d)) + + +### Bug Fixes + +* do not break `@scope` at-rule without params ([#1581](https://github.com/webpack-contrib/css-loader/issues/1581)) ([e022e3b](https://github.com/webpack-contrib/css-loader/commit/e022e3bb405472ac7d51ff1114783fc2811dfe04)) + ## [6.10.0](https://github.com/webpack-contrib/css-loader/compare/v6.9.1...v6.10.0) (2024-01-30) diff --git a/package-lock.json b/package-lock.json index 3786e3f3..8e6e137e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "css-loader", - "version": "6.10.0", + "version": "6.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "css-loader", - "version": "6.10.0", + "version": "6.11.0", "license": "MIT", "dependencies": { "icss-utils": "^5.1.0", diff --git a/package.json b/package.json index fd71a2b5..c168712a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "6.10.0", + "version": "6.11.0", "description": "css loader module for webpack", "license": "MIT", "repository": "webpack-contrib/css-loader",