From 7554570873cef41fe4f968fbe2f5419d6b7594eb Mon Sep 17 00:00:00 2001 From: pshu Date: Mon, 27 Jan 2025 01:44:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?test:=20=E2=9C=85=20change=20two=20skipped?= =?UTF-8?q?=20case=20to=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/webpack-test/Compiler.test.js | 116 ++++++++++-------- .../fixtures/node_modules/complexm/step1.js | 1 + .../fixtures/node_modules/complexm/step2.js | 1 + .../fixtures/node_modules/m1/a.js | 3 + .../fixtures/node_modules/m1/b.js | 3 + .../fixtures/node_modules/m2-loader/b.js | 3 + .../fixtures/node_modules/m2/b.js | 1 + 7 files changed, 80 insertions(+), 48 deletions(-) create mode 100644 tests/webpack-test/fixtures/node_modules/complexm/step1.js create mode 100644 tests/webpack-test/fixtures/node_modules/complexm/step2.js create mode 100644 tests/webpack-test/fixtures/node_modules/m1/a.js create mode 100644 tests/webpack-test/fixtures/node_modules/m1/b.js create mode 100644 tests/webpack-test/fixtures/node_modules/m2-loader/b.js create mode 100644 tests/webpack-test/fixtures/node_modules/m2/b.js diff --git a/tests/webpack-test/Compiler.test.js b/tests/webpack-test/Compiler.test.js index 97c652ebb1d9..b58d9aa045a4 100644 --- a/tests/webpack-test/Compiler.test.js +++ b/tests/webpack-test/Compiler.test.js @@ -12,7 +12,7 @@ const { normalizeFilteredTestName, FilteredStatus } = require("./lib/util/filter describe("Compiler", () => { jest.setTimeout(20000); - function compile(entry, options, callback) { + function compile(entry, options, callback, done = () => {}) { const noOutputPath = !options.output || !options.output.path; const webpack = require("@rspack/core"); options = webpack.config.getNormalizedWebpackOptions(options); @@ -20,8 +20,7 @@ describe("Compiler", () => { options.entry = entry; options.context = path.join(__dirname, "fixtures"); if (noOutputPath) options.output.path = "/"; - // CHANGE: The pathinfo is currently not supported in rspack - // options.output.pathinfo = true; + options.output.pathinfo = true; options.optimization = { minimize: false }; @@ -81,7 +80,11 @@ describe("Compiler", () => { stats.logs = logs; c.close(err => { if (err) return callback(err); - callback(stats, files, compilation); + try { + callback(stats, files, compilation); + } catch (e) { + done(e); + } }); }); } @@ -117,6 +120,7 @@ describe("Compiler", () => { }); // CHANGE: skip due to Rspack defaults to numerical module ids, unlike webpack's string-based ids + // TODO: ModuleInfoHeaderPlugin it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should compile a single file"), done => { compile("./c", {}, (stats, files) => { expect(Object.keys(files)).toEqual(["/main.js"]); @@ -132,56 +136,74 @@ describe("Compiler", () => { expect(bundle).not.toMatch("jsonp"); expect(bundle).not.toMatch("fixtures"); done(); - }); + }, + done + ); }); // CHANGE: skip with custom test name for tracking alignment status + // TODO: ModuleInfoHeaderPlugin it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should compile a complex file"), done => { - compile("./main1", {}, (stats, files) => { - expect(Object.keys(files)).toEqual(["/main.js"]); - const bundle = files["/main.js"]; - expect(bundle).toMatch("function __webpack_require__("); - expect(bundle).toMatch("__webpack_require__(/*! ./a */"); - expect(bundle).toMatch("./main1.js"); - expect(bundle).toMatch("./a.js"); - expect(bundle).toMatch("./b.js"); - expect(bundle).toMatch("./node_modules/m1/a.js"); - expect(bundle).toMatch("This is a"); - expect(bundle).toMatch("This is b"); - expect(bundle).toMatch("This is m1/a"); - expect(bundle).not.toMatch("4: function("); - expect(bundle).not.toMatch("window"); - expect(bundle).not.toMatch("jsonp"); - expect(bundle).not.toMatch("fixtures"); - done(); - }); + compile( + "./main1", + {}, + (stats, files) => { + expect(Object.keys(files)).toEqual(["/main.js"]); + const bundle = files["/main.js"]; + expect(bundle).toMatch("function __webpack_require__("); + expect(bundle).toMatch("__webpack_require__(/*! ./a */"); + expect(bundle).toMatch("./main1.js"); + expect(bundle).toMatch("./a.js"); + expect(bundle).toMatch("./b.js"); + expect(bundle).toMatch("./node_modules/m1/a.js"); + expect(bundle).toMatch("This is a"); + expect(bundle).toMatch("This is b"); + expect(bundle).toMatch("This is m1/a"); + expect(bundle).not.toMatch("4: function("); + expect(bundle).not.toMatch("window"); + expect(bundle).not.toMatch("jsonp"); + expect(bundle).not.toMatch("fixtures"); + done(); + }, + done + ); }); // CHANGE: skip with custom test name for tracking alignment status - it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should compile a file with transitive dependencies"), done => { - compile("./abc", {}, (stats, files) => { - expect(Object.keys(files)).toEqual(["/main.js"]); - const bundle = files["/main.js"]; - expect(bundle).toMatch("function __webpack_require__("); - expect(bundle).toMatch("__webpack_require__(/*! ./a */"); - expect(bundle).toMatch("__webpack_require__(/*! ./b */"); - expect(bundle).toMatch("__webpack_require__(/*! ./c */"); - expect(bundle).toMatch("./abc.js"); - expect(bundle).toMatch("./a.js"); - expect(bundle).toMatch("./b.js"); - expect(bundle).toMatch("./c.js"); - expect(bundle).toMatch("This is a"); - expect(bundle).toMatch("This is b"); - expect(bundle).toMatch("This is c"); - expect(bundle).not.toMatch("4: function("); - expect(bundle).not.toMatch("window"); - expect(bundle).not.toMatch("jsonp"); - expect(bundle).not.toMatch("fixtures"); - done(); - }); + // TODO: ModuleInfoHeaderPlugin.js + it.skip(normalizeFilteredTestName( + FilteredStatus.TODO, + "should compile a file with transitive dependencies" + ), done => { + compile( + "./abc", + {}, + (stats, files) => { + expect(Object.keys(files)).toEqual(["/main.js"]); + const bundle = files["/main.js"]; + expect(bundle).toMatch("function __webpack_require__("); + expect(bundle).toMatch("__webpack_require__(/*! ./a */"); + expect(bundle).toMatch("__webpack_require__(/*! ./b */"); + expect(bundle).toMatch("__webpack_require__(/*! ./c */"); + expect(bundle).toMatch("./abc.js"); + expect(bundle).toMatch("./a.js"); + expect(bundle).toMatch("./b.js"); + expect(bundle).toMatch("./c.js"); + expect(bundle).toMatch("This is a"); + expect(bundle).toMatch("This is b"); + expect(bundle).toMatch("This is c"); + expect(bundle).not.toMatch("4: function("); + expect(bundle).not.toMatch("window"); + expect(bundle).not.toMatch("jsonp"); + expect(bundle).not.toMatch("fixtures"); + done(); + }, + done + ); }); // CHANGE: skip with custom test name for tracking alignment status + // TODO: ModuleInfoHeaderPlugin CodeSplitting it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should compile a file with multiple chunks"), done => { compile("./chunks", {}, (stats, files) => { expect(stats.chunks).toHaveLength(2); @@ -699,7 +721,7 @@ describe("Compiler", () => { }); // CHANGE: skip with custom test name for tracking alignment status // CHANGE: skip due to panic occurred at runtime - it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should call afterDone hook after other callbacks (watch)"), done => { + it("should call afterDone hook after other callbacks (watch)", done => { const webpack = require("@rspack/core"); compiler = webpack({ context: __dirname, @@ -788,9 +810,7 @@ describe("Compiler", () => { }); }); }); - // CHANGE: skip with custom test name for tracking alignment status - // CHANGE: skip due to panic occurred at runtime - it.skip(normalizeFilteredTestName(FilteredStatus.TODO, "should use cache on second run call"), done => { + it("should use cache on second run call", done => { const webpack = require("@rspack/core"); compiler = webpack({ context: __dirname, diff --git a/tests/webpack-test/fixtures/node_modules/complexm/step1.js b/tests/webpack-test/fixtures/node_modules/complexm/step1.js new file mode 100644 index 000000000000..30dfd778c02e --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/complexm/step1.js @@ -0,0 +1 @@ +module.exports = require("m1/a") + require("m1"); \ No newline at end of file diff --git a/tests/webpack-test/fixtures/node_modules/complexm/step2.js b/tests/webpack-test/fixtures/node_modules/complexm/step2.js new file mode 100644 index 000000000000..10bad86c9d3e --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/complexm/step2.js @@ -0,0 +1 @@ +module.exports = "Step2"; \ No newline at end of file diff --git a/tests/webpack-test/fixtures/node_modules/m1/a.js b/tests/webpack-test/fixtures/node_modules/m1/a.js new file mode 100644 index 000000000000..271f8a7adf21 --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/m1/a.js @@ -0,0 +1,3 @@ +module.exports = function a() { + return "This is m1/a"; +}; \ No newline at end of file diff --git a/tests/webpack-test/fixtures/node_modules/m1/b.js b/tests/webpack-test/fixtures/node_modules/m1/b.js new file mode 100644 index 000000000000..b603c435534b --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/m1/b.js @@ -0,0 +1,3 @@ +module.exports = function a() { + return "This is m1/b"; +}; \ No newline at end of file diff --git a/tests/webpack-test/fixtures/node_modules/m2-loader/b.js b/tests/webpack-test/fixtures/node_modules/m2-loader/b.js new file mode 100644 index 000000000000..08b1d8cb392d --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/m2-loader/b.js @@ -0,0 +1,3 @@ +module.exports = function() { + "module.exports = 'This is m2-loader/b';"; +} diff --git a/tests/webpack-test/fixtures/node_modules/m2/b.js b/tests/webpack-test/fixtures/node_modules/m2/b.js new file mode 100644 index 000000000000..34faaaf517e8 --- /dev/null +++ b/tests/webpack-test/fixtures/node_modules/m2/b.js @@ -0,0 +1 @@ +module.exports = "This is m2/b"; From 598281b124b15682a4dc3c499eb0baa6307199de Mon Sep 17 00:00:00 2001 From: pshu Date: Tue, 4 Feb 2025 21:18:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore(ci):=20=F0=9F=94=A7=20just=20update?= =?UTF-8?q?=20corepack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/pnpm-cache/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/pnpm-cache/action.yml b/.github/actions/pnpm-cache/action.yml index 633d6b8ff2b7..fa8368e1b898 100644 --- a/.github/actions/pnpm-cache/action.yml +++ b/.github/actions/pnpm-cache/action.yml @@ -28,8 +28,7 @@ runs: if: ${{ inputs.node-version != '16' }} shell: bash run: | - corepack enable - + npm i -g --force corepack && which -a corepack && corepack enable # https://pnpm.io/continuous-integration#github-actions # Uses `packageManagement` field from package.json - name: Install pnpm From af53a5262ac4fd67a44a557745b9cb5059e5db95 Mon Sep 17 00:00:00 2001 From: pshu Date: Thu, 6 Feb 2025 14:59:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=F0=9F=94=A5=20delete=20dead=20fil?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/webpack-test/fixtures/node_modules/complexm/step1.js | 1 - tests/webpack-test/fixtures/node_modules/complexm/step2.js | 1 - 2 files changed, 2 deletions(-) delete mode 100644 tests/webpack-test/fixtures/node_modules/complexm/step1.js delete mode 100644 tests/webpack-test/fixtures/node_modules/complexm/step2.js diff --git a/tests/webpack-test/fixtures/node_modules/complexm/step1.js b/tests/webpack-test/fixtures/node_modules/complexm/step1.js deleted file mode 100644 index 30dfd778c02e..000000000000 --- a/tests/webpack-test/fixtures/node_modules/complexm/step1.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("m1/a") + require("m1"); \ No newline at end of file diff --git a/tests/webpack-test/fixtures/node_modules/complexm/step2.js b/tests/webpack-test/fixtures/node_modules/complexm/step2.js deleted file mode 100644 index 10bad86c9d3e..000000000000 --- a/tests/webpack-test/fixtures/node_modules/complexm/step2.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = "Step2"; \ No newline at end of file