From c7f81ebdce3a1df202c3c4538785676744487708 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 7 Jun 2021 15:55:22 +0530 Subject: [PATCH 1/4] chore: fix typo (#1318) --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index f68cbd3e..3ce9cf32 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -6,7 +6,7 @@ You arrived at this template because you felt none of the other options matched the kind of issue you'd like to report. Please use this opportunity to - tell us about your particular type of issue so we can try to accomodate + tell us about your particular type of issue so we can try to accommodate similar issues in the future. PLEASE do note, if you're using this to report an issue already covered by the From adcc4382992d99e24b54f39418d64ff4edf7272c Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Tue, 13 Jul 2021 15:09:10 +0530 Subject: [PATCH 2/4] ci: use `actions/setup-node@v2` (#1323) --- .github/workflows/nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 98ecd856..0302d02a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -30,7 +30,7 @@ jobs: fetch-depth: 0 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} @@ -68,7 +68,7 @@ jobs: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} From bb76fe48a198e74cacf29ad4b1c01d485f4db11f Mon Sep 17 00:00:00 2001 From: Alexey Lavinsky Date: Tue, 13 Jul 2021 06:00:34 -0700 Subject: [PATCH 3/4] fix: fix crash when source map is unavailable with external URL in `@import` --- src/runtime/cssWithMappingToString.js | 4 ++++ test/runtime/__snapshots__/api.test.js.snap | 2 ++ test/runtime/api.test.js | 12 ++++++++++++ test/sourceMap-option.test.js | 4 ++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/runtime/cssWithMappingToString.js b/src/runtime/cssWithMappingToString.js index 2a7fda69..e6c7603f 100644 --- a/src/runtime/cssWithMappingToString.js +++ b/src/runtime/cssWithMappingToString.js @@ -1,6 +1,10 @@ module.exports = function cssWithMappingToString(item) { const [, content, , cssMapping] = item; + if (!cssMapping) { + return content; + } + if (typeof btoa === "function") { // eslint-disable-next-line no-undef const base64 = btoa( diff --git a/test/runtime/__snapshots__/api.test.js.snap b/test/runtime/__snapshots__/api.test.js.snap index 3304a234..03a55291 100644 --- a/test/runtime/__snapshots__/api.test.js.snap +++ b/test/runtime/__snapshots__/api.test.js.snap @@ -18,6 +18,8 @@ exports[`api should toString with a source map without "sourceRoot" 1`] = ` /*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC5zY3NzIiwic291cmNlcyI6WyIuL3BhdGgvdG8vdGVzdC5zY3NzIl0sIm1hcHBpbmdzIjoiQUFBQTsifQ== */" `; +exports[`api should toString with a source map without map 1`] = `"@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');"`; + exports[`api should toString with media query 1`] = `"body { b: 2; }body { c: 3; }body { b: 2; }@media print {body { b: 2; }}@media print {body { d: 4; }}@media screen {body { a: 1; }}"`; exports[`api should toString with source mapping 1`] = ` diff --git a/test/runtime/api.test.js b/test/runtime/api.test.js index 7c1bbaf7..337ddeec 100644 --- a/test/runtime/api.test.js +++ b/test/runtime/api.test.js @@ -145,6 +145,18 @@ describe("api", () => { expect(m.toString()).toMatchSnapshot(); }); + // https://github.com/webpack-contrib/css-loader/issues/1322 + it("should toString with a source map without map", () => { + const m = api(cssWithMappingToString); + + m.push([ + 1, + "@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');", + ]); + + expect(m.toString()).toMatchSnapshot(); + }); + it("should import modules with dedupe", () => { const m = api((i) => i[1]); diff --git a/test/sourceMap-option.test.js b/test/sourceMap-option.test.js index 635e7fc4..3d0c695a 100644 --- a/test/sourceMap-option.test.js +++ b/test/sourceMap-option.test.js @@ -501,8 +501,8 @@ describe('"sourceMap" option', () => { expect(chunkName).toBe( webpack.version[0] === "5" - ? "main.6480a869998e0b381c90.bundle.js" - : "main.19efc497c5c37fc5e355.bundle.js" + ? "main.b67984bbf9dd298785fb.bundle.js" + : "main.a64c858ed0f4c1ed322c.bundle.js" ); expect( getModuleSource("fixtures/source-map/basic.css", stats) From ae988451a9638662625e515b915a12f6e2c9378a Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 13 Jul 2021 16:01:13 +0300 Subject: [PATCH 4/4] chore(release): 5.2.7 --- CHANGELOG.md | 7 +++++++ package-lock.json | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cf68971..f76674d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ 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. +### [5.2.7](https://github.com/webpack-contrib/css-loader/compare/v5.2.6...v5.2.7) (2021-07-13) + + +### Bug Fixes + +* fix crash when source map is unavailable with external URL in `[@import](https://github.com/import)` ([bb76fe4](https://github.com/webpack-contrib/css-loader/commit/bb76fe48a198e74cacf29ad4b1c01d485f4db11f)) + ### [5.2.6](https://github.com/webpack-contrib/css-loader/compare/v5.2.5...v5.2.6) (2021-05-24) diff --git a/package-lock.json b/package-lock.json index 6c20a63e..bc827dda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "5.2.6", + "version": "5.2.7", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index a73a9a8b..8ea4bb8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "5.2.6", + "version": "5.2.7", "description": "css loader module for webpack", "license": "MIT", "repository": "webpack-contrib/css-loader",