From 05dec9cfeba80758d9aa8189e4e376a61f9426ed Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 19 Feb 2024 21:07:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20enable=20more=20tes?= =?UTF-8?q?ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic/package.json | 6 +++ examples/basic/rspack.config.js | 18 +++++++++ examples/basic/src/answer.js | 1 + examples/basic/src/index.js | 14 +++++++ examples/basic/src/lib.js | 1 + examples/runtime-specific-used-exports2/1.js | 26 ++++++++++++ examples/runtime-specific-used-exports2/2.js | 40 +++++++++++++++++++ examples/runtime-specific-used-exports2/3.js | 40 +++++++++++++++++++ .../runtime-specific-used-exports2/helper.js | 18 +++++++++ .../package.json | 9 +++++ .../runtime-specific-used-exports2/path1.js | 4 ++ .../runtime-specific-used-exports2/path2.js | 6 +++ .../reexport-all.js | 2 + .../rspack.config.js | 25 ++++++++++++ .../test.config.js | 9 +++++ .../test.filter.js | 1 + .../webpack.config.js | 24 +++++++++++ pnpm-lock.yaml | 8 ++++ .../export-imported-global/test.filter.js | 2 +- .../test.filter.js | 2 +- .../node_modules/root1/index.js | 6 +++ .../node_modules/root2/index.js | 6 +++ .../test.config.js | 1 + .../test.filter.js | 2 +- .../webpack.config.js | 6 +++ .../node_modules/dummy_module/index.js | 3 ++ .../output/inner-dirs-entries/test.filter.js | 2 +- 27 files changed, 278 insertions(+), 4 deletions(-) create mode 100644 examples/basic/package.json create mode 100644 examples/basic/rspack.config.js create mode 100644 examples/basic/src/answer.js create mode 100644 examples/basic/src/index.js create mode 100644 examples/basic/src/lib.js create mode 100644 examples/runtime-specific-used-exports2/1.js create mode 100644 examples/runtime-specific-used-exports2/2.js create mode 100644 examples/runtime-specific-used-exports2/3.js create mode 100644 examples/runtime-specific-used-exports2/helper.js create mode 100644 examples/runtime-specific-used-exports2/package.json create mode 100644 examples/runtime-specific-used-exports2/path1.js create mode 100644 examples/runtime-specific-used-exports2/path2.js create mode 100644 examples/runtime-specific-used-exports2/reexport-all.js create mode 100644 examples/runtime-specific-used-exports2/rspack.config.js create mode 100644 examples/runtime-specific-used-exports2/test.config.js create mode 100644 examples/runtime-specific-used-exports2/test.filter.js create mode 100644 examples/runtime-specific-used-exports2/webpack.config.js create mode 100644 webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root1/index.js create mode 100644 webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root2/index.js create mode 100644 webpack-test/configCases/output/inner-dirs-entries/node_modules/dummy_module/index.js diff --git a/examples/basic/package.json b/examples/basic/package.json new file mode 100644 index 00000000000..2410516785f --- /dev/null +++ b/examples/basic/package.json @@ -0,0 +1,6 @@ +{ + "scripts":{ + "build": "rspack build", + "dev": "rspack dev" + } +} diff --git a/examples/basic/rspack.config.js b/examples/basic/rspack.config.js new file mode 100644 index 00000000000..d3e487faaf6 --- /dev/null +++ b/examples/basic/rspack.config.js @@ -0,0 +1,18 @@ +const rspack = require('@rspack/core') +/**@type {import("@rspack/cli").Configuration}*/ +module.exports = { + entry: { + main: "./src/index.js", + }, + optimization: { + concatenateModules: true, + minimize: false, + }, + experiments: { + rspackFuture: { + newTreeshaking: true, + }, + }, + plugins: [new rspack.HtmlRspackPlugin({ + })] +}; diff --git a/examples/basic/src/answer.js b/examples/basic/src/answer.js new file mode 100644 index 00000000000..dd0c409bbc5 --- /dev/null +++ b/examples/basic/src/answer.js @@ -0,0 +1 @@ +export const answer = 103330 diff --git a/examples/basic/src/index.js b/examples/basic/src/index.js new file mode 100644 index 00000000000..c93b7adc89f --- /dev/null +++ b/examples/basic/src/index.js @@ -0,0 +1,14 @@ +import { answer as some } from "./lib"; +console.log('some: ', some) + +function answer() { + +} + +console.log('answer(): ', answer()) + +function test() { + +} + + diff --git a/examples/basic/src/lib.js b/examples/basic/src/lib.js new file mode 100644 index 00000000000..c7c1e6c602d --- /dev/null +++ b/examples/basic/src/lib.js @@ -0,0 +1 @@ +export {answer} from './answer.js' diff --git a/examples/runtime-specific-used-exports2/1.js b/examples/runtime-specific-used-exports2/1.js new file mode 100644 index 00000000000..49b9fffd894 --- /dev/null +++ b/examples/runtime-specific-used-exports2/1.js @@ -0,0 +1,26 @@ +import { + e, + _1 +} from "./path1"; +import { + aUsed, + bUsed, + cUsed +} from "root1"; +import { + dUsed, + eUsed, + fUsed +} from "root2"; + +it("should use only current entrypoint exports", () => { + expect(e).toBe("e"); + expect(_1.a).toBe("a"); + expect(_1.c).toBe("c"); + expect(aUsed).toBe(true); + expect(bUsed).toBe(false); + expect(cUsed).toBe(true); + expect(dUsed).toBe(false); + expect(eUsed).toBe(true); + expect(fUsed).toBe(false); +}); diff --git a/examples/runtime-specific-used-exports2/2.js b/examples/runtime-specific-used-exports2/2.js new file mode 100644 index 00000000000..2c2d207303e --- /dev/null +++ b/examples/runtime-specific-used-exports2/2.js @@ -0,0 +1,40 @@ +import { + b, + _2 +} from "./path2"; +import { + aUsed, + bUsed, + cUsed +} from "root1"; +import { + dUsed, + eUsed, + fUsed +} from "root2"; +import {addFiles, isSame} from "./helper"; + +// should be the same as 3.js and reuse defaultVendors +it("should use only current entrypoint exports", () => { + expect(b).toBe("b"); + expect(_2.f).toBe("f"); + expect(aUsed).toBe(false); + expect(bUsed).toBe(true); + expect(cUsed).toBe(false); + expect(dUsed).toBe(false); + expect(eUsed).toBe(false); + expect(fUsed).toBe(true); + + const files = new Set(); + + addFiles( + files, + __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b"])) + ); + addFiles( + files, + __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b", "c"])) + ); + + expect(files.size).toBe(2); +}); diff --git a/examples/runtime-specific-used-exports2/3.js b/examples/runtime-specific-used-exports2/3.js new file mode 100644 index 00000000000..04c6871b6fa --- /dev/null +++ b/examples/runtime-specific-used-exports2/3.js @@ -0,0 +1,40 @@ +import { + b, + _2 +} from "./path2"; +import { + aUsed, + bUsed, + cUsed +} from "root1"; +import { + dUsed, + eUsed, + fUsed +} from "root2"; +import { addFiles, isSame } from "./helper"; + +// should be the same as 2.js and reuse defaultVendors +it("should use only current entrypoint exports", () => { + expect(b).toBe("b"); + expect(_2.f).toBe("f"); + expect(aUsed).toBe(false); + expect(bUsed).toBe(true); + expect(cUsed).toBe(false); + expect(dUsed).toBe(false); + expect(eUsed).toBe(false); + expect(fUsed).toBe(true); + + const files = new Set(); + + addFiles( + files, + __STATS__.chunks.filter(ch => isSame(ch.runtime, ["c"])) + ); + addFiles( + files, + __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b", "c"])) + ); + + expect(files.size).toBe(2); +}); diff --git a/examples/runtime-specific-used-exports2/helper.js b/examples/runtime-specific-used-exports2/helper.js new file mode 100644 index 00000000000..0263269dfa5 --- /dev/null +++ b/examples/runtime-specific-used-exports2/helper.js @@ -0,0 +1,18 @@ +/** + * @template T + * @param {T[]} arr arr + * @param {T[]} expected expected + * @returns {boolean} is same + */ +export function isSame(arr, expected) { + const set = new Set(arr); + return expected.every(i => set.has(i)); +} + +/** + * @param {Set} files + * @param {{files: string[]}[]} chunks + */ +export function addFiles(files, chunks) { + chunks.forEach(ch => ch.files.forEach(f => files.add(f))); +} diff --git a/examples/runtime-specific-used-exports2/package.json b/examples/runtime-specific-used-exports2/package.json new file mode 100644 index 00000000000..0318e20f9bb --- /dev/null +++ b/examples/runtime-specific-used-exports2/package.json @@ -0,0 +1,9 @@ +{ + "scripts":{ + "build": "rspack build", + "dev": "rspack dev" + }, + "devDependencies": { + "@rspack/core": "workspace:^" + } +} diff --git a/examples/runtime-specific-used-exports2/path1.js b/examples/runtime-specific-used-exports2/path1.js new file mode 100644 index 00000000000..9ba7bd7c36e --- /dev/null +++ b/examples/runtime-specific-used-exports2/path1.js @@ -0,0 +1,4 @@ +import { _1, _2 } from "./reexport-all"; +import { e, d } from "root2"; + +export { _1, e }; diff --git a/examples/runtime-specific-used-exports2/path2.js b/examples/runtime-specific-used-exports2/path2.js new file mode 100644 index 00000000000..37dcfbbddf0 --- /dev/null +++ b/examples/runtime-specific-used-exports2/path2.js @@ -0,0 +1,6 @@ +import { _1 } from "./path1"; +import { _2 } from "./reexport-all"; + +const b = _1.b; + +export { b, _2 } diff --git a/examples/runtime-specific-used-exports2/reexport-all.js b/examples/runtime-specific-used-exports2/reexport-all.js new file mode 100644 index 00000000000..4ef0128938e --- /dev/null +++ b/examples/runtime-specific-used-exports2/reexport-all.js @@ -0,0 +1,2 @@ +export * as _1 from "root1"; +export * as _2 from "root2"; diff --git a/examples/runtime-specific-used-exports2/rspack.config.js b/examples/runtime-specific-used-exports2/rspack.config.js new file mode 100644 index 00000000000..3f0bcf0079a --- /dev/null +++ b/examples/runtime-specific-used-exports2/rspack.config.js @@ -0,0 +1,25 @@ +const rspack = require("@rspack/core"); +/**@type {import("@rspack/cli").Configuration}*/ +module.exports = { + output: { + filename: "[name].js" + }, + target: "node", + optimization: { + chunkIds: "named", + splitChunks: { + chunks: "all", + cacheGroups: { + defaultVendors: { + test: /[\\/]node_modules[\\/]/, + enforce: true + } + } + } + }, + entry: { + a: "./1", + b: "./2", + c: "./3" + } +}; diff --git a/examples/runtime-specific-used-exports2/test.config.js b/examples/runtime-specific-used-exports2/test.config.js new file mode 100644 index 00000000000..c5938acd51c --- /dev/null +++ b/examples/runtime-specific-used-exports2/test.config.js @@ -0,0 +1,9 @@ +module.exports = { + findBundle: function() { + return [ + "./a.js", + "./b.js", + "./c.js" + ]; + } +}; diff --git a/examples/runtime-specific-used-exports2/test.filter.js b/examples/runtime-specific-used-exports2/test.filter.js new file mode 100644 index 00000000000..3be456dcd23 --- /dev/null +++ b/examples/runtime-specific-used-exports2/test.filter.js @@ -0,0 +1 @@ +module.exports = () => {return false} \ No newline at end of file diff --git a/examples/runtime-specific-used-exports2/webpack.config.js b/examples/runtime-specific-used-exports2/webpack.config.js new file mode 100644 index 00000000000..0895dba239b --- /dev/null +++ b/examples/runtime-specific-used-exports2/webpack.config.js @@ -0,0 +1,24 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + output: { + filename: "[name].js" + }, + target: "node", + optimization: { + chunkIds: "named", + splitChunks: { + chunks: "all", + cacheGroups: { + defaultVendors: { + test: /[\\/]node_modules[\\/]/, + enforce: true + } + } + } + }, + entry: { + a: "./1", + b: "./2", + c: "./3" + } +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e630e2ff161..b3d202bc1d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -248,6 +248,14 @@ importers: specifier: ^5.90.0 version: 5.90.0(@swc/core@1.3.23)(webpack-cli@4.10.0) + examples/basic: {} + + examples/runtime-specific-used-exports2: + devDependencies: + '@rspack/core': + specifier: workspace:^ + version: link:../../packages/rspack + npm/darwin-arm64: {} npm/darwin-x64: {} diff --git a/webpack-test/cases/wasm/export-imported-global/test.filter.js b/webpack-test/cases/wasm/export-imported-global/test.filter.js index 23177349638..c32d75292eb 100644 --- a/webpack-test/cases/wasm/export-imported-global/test.filter.js +++ b/webpack-test/cases/wasm/export-imported-global/test.filter.js @@ -1,5 +1,5 @@ var supportsWebAssembly = require("../../../helpers/supportsWebAssembly"); module.exports = function(config) { - return supportsWebAssembly(); + return false }; diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports/test.filter.js b/webpack-test/configCases/optimization/runtime-specific-used-exports/test.filter.js index 3be456dcd23..8e5c51af343 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports/test.filter.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports/test.filter.js @@ -1 +1 @@ -module.exports = () => {return false} \ No newline at end of file +module.exports = () => {return true} diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root1/index.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root1/index.js new file mode 100644 index 00000000000..7d4533e46be --- /dev/null +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root1/index.js @@ -0,0 +1,6 @@ +export const a = "a"; +export const b = "b"; +export const c = "c"; +export const aUsed = __webpack_exports_info__.a.used; +export const bUsed = __webpack_exports_info__.b.used; +export const cUsed = __webpack_exports_info__.c.used; diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root2/index.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root2/index.js new file mode 100644 index 00000000000..524350cd31b --- /dev/null +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/node_modules/root2/index.js @@ -0,0 +1,6 @@ +export const d = "d"; +export const e = "e"; +export const f = "f"; +export const dUsed = __webpack_exports_info__.d.used; +export const eUsed = __webpack_exports_info__.e.used; +export const fUsed = __webpack_exports_info__.f.used; diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js index c5938acd51c..0b00d71ce8c 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js @@ -1,5 +1,6 @@ module.exports = { findBundle: function() { + return [ "./a.js", "./b.js", diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js index 3be456dcd23..8e5c51af343 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js @@ -1 +1 @@ -module.exports = () => {return false} \ No newline at end of file +module.exports = () => {return true} diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/webpack.config.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/webpack.config.js index 0895dba239b..d7ff8eeb2f5 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports2/webpack.config.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/webpack.config.js @@ -4,8 +4,14 @@ module.exports = { filename: "[name].js" }, target: "node", + experiments: { + rspackFuture: { + newTreeshaking: true + } + }, optimization: { chunkIds: "named", + usedExports: true, splitChunks: { chunks: "all", cacheGroups: { diff --git a/webpack-test/configCases/output/inner-dirs-entries/node_modules/dummy_module/index.js b/webpack-test/configCases/output/inner-dirs-entries/node_modules/dummy_module/index.js new file mode 100644 index 00000000000..bb16bd21190 --- /dev/null +++ b/webpack-test/configCases/output/inner-dirs-entries/node_modules/dummy_module/index.js @@ -0,0 +1,3 @@ +export default function someDummyFunction() { + return "this is just a dummy function"; +} diff --git a/webpack-test/configCases/output/inner-dirs-entries/test.filter.js b/webpack-test/configCases/output/inner-dirs-entries/test.filter.js index 3be456dcd23..8e5c51af343 100644 --- a/webpack-test/configCases/output/inner-dirs-entries/test.filter.js +++ b/webpack-test/configCases/output/inner-dirs-entries/test.filter.js @@ -1 +1 @@ -module.exports = () => {return false} \ No newline at end of file +module.exports = () => {return true} From 0fbc5c821308f1135b1b188bcaf87ec60fd397b7 Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 19 Feb 2024 21:26:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20clean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/basic/package.json | 6 --- examples/basic/rspack.config.js | 18 --------- examples/basic/src/answer.js | 1 - examples/basic/src/index.js | 14 ------- examples/basic/src/lib.js | 1 - examples/runtime-specific-used-exports2/1.js | 26 ------------ examples/runtime-specific-used-exports2/2.js | 40 ------------------- examples/runtime-specific-used-exports2/3.js | 40 ------------------- .../runtime-specific-used-exports2/helper.js | 18 --------- .../package.json | 9 ----- .../runtime-specific-used-exports2/path1.js | 4 -- .../runtime-specific-used-exports2/path2.js | 6 --- .../reexport-all.js | 2 - .../rspack.config.js | 25 ------------ .../test.config.js | 9 ----- .../test.filter.js | 1 - .../webpack.config.js | 24 ----------- 17 files changed, 244 deletions(-) delete mode 100644 examples/basic/package.json delete mode 100644 examples/basic/rspack.config.js delete mode 100644 examples/basic/src/answer.js delete mode 100644 examples/basic/src/index.js delete mode 100644 examples/basic/src/lib.js delete mode 100644 examples/runtime-specific-used-exports2/1.js delete mode 100644 examples/runtime-specific-used-exports2/2.js delete mode 100644 examples/runtime-specific-used-exports2/3.js delete mode 100644 examples/runtime-specific-used-exports2/helper.js delete mode 100644 examples/runtime-specific-used-exports2/package.json delete mode 100644 examples/runtime-specific-used-exports2/path1.js delete mode 100644 examples/runtime-specific-used-exports2/path2.js delete mode 100644 examples/runtime-specific-used-exports2/reexport-all.js delete mode 100644 examples/runtime-specific-used-exports2/rspack.config.js delete mode 100644 examples/runtime-specific-used-exports2/test.config.js delete mode 100644 examples/runtime-specific-used-exports2/test.filter.js delete mode 100644 examples/runtime-specific-used-exports2/webpack.config.js diff --git a/examples/basic/package.json b/examples/basic/package.json deleted file mode 100644 index 2410516785f..00000000000 --- a/examples/basic/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "scripts":{ - "build": "rspack build", - "dev": "rspack dev" - } -} diff --git a/examples/basic/rspack.config.js b/examples/basic/rspack.config.js deleted file mode 100644 index d3e487faaf6..00000000000 --- a/examples/basic/rspack.config.js +++ /dev/null @@ -1,18 +0,0 @@ -const rspack = require('@rspack/core') -/**@type {import("@rspack/cli").Configuration}*/ -module.exports = { - entry: { - main: "./src/index.js", - }, - optimization: { - concatenateModules: true, - minimize: false, - }, - experiments: { - rspackFuture: { - newTreeshaking: true, - }, - }, - plugins: [new rspack.HtmlRspackPlugin({ - })] -}; diff --git a/examples/basic/src/answer.js b/examples/basic/src/answer.js deleted file mode 100644 index dd0c409bbc5..00000000000 --- a/examples/basic/src/answer.js +++ /dev/null @@ -1 +0,0 @@ -export const answer = 103330 diff --git a/examples/basic/src/index.js b/examples/basic/src/index.js deleted file mode 100644 index c93b7adc89f..00000000000 --- a/examples/basic/src/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import { answer as some } from "./lib"; -console.log('some: ', some) - -function answer() { - -} - -console.log('answer(): ', answer()) - -function test() { - -} - - diff --git a/examples/basic/src/lib.js b/examples/basic/src/lib.js deleted file mode 100644 index c7c1e6c602d..00000000000 --- a/examples/basic/src/lib.js +++ /dev/null @@ -1 +0,0 @@ -export {answer} from './answer.js' diff --git a/examples/runtime-specific-used-exports2/1.js b/examples/runtime-specific-used-exports2/1.js deleted file mode 100644 index 49b9fffd894..00000000000 --- a/examples/runtime-specific-used-exports2/1.js +++ /dev/null @@ -1,26 +0,0 @@ -import { - e, - _1 -} from "./path1"; -import { - aUsed, - bUsed, - cUsed -} from "root1"; -import { - dUsed, - eUsed, - fUsed -} from "root2"; - -it("should use only current entrypoint exports", () => { - expect(e).toBe("e"); - expect(_1.a).toBe("a"); - expect(_1.c).toBe("c"); - expect(aUsed).toBe(true); - expect(bUsed).toBe(false); - expect(cUsed).toBe(true); - expect(dUsed).toBe(false); - expect(eUsed).toBe(true); - expect(fUsed).toBe(false); -}); diff --git a/examples/runtime-specific-used-exports2/2.js b/examples/runtime-specific-used-exports2/2.js deleted file mode 100644 index 2c2d207303e..00000000000 --- a/examples/runtime-specific-used-exports2/2.js +++ /dev/null @@ -1,40 +0,0 @@ -import { - b, - _2 -} from "./path2"; -import { - aUsed, - bUsed, - cUsed -} from "root1"; -import { - dUsed, - eUsed, - fUsed -} from "root2"; -import {addFiles, isSame} from "./helper"; - -// should be the same as 3.js and reuse defaultVendors -it("should use only current entrypoint exports", () => { - expect(b).toBe("b"); - expect(_2.f).toBe("f"); - expect(aUsed).toBe(false); - expect(bUsed).toBe(true); - expect(cUsed).toBe(false); - expect(dUsed).toBe(false); - expect(eUsed).toBe(false); - expect(fUsed).toBe(true); - - const files = new Set(); - - addFiles( - files, - __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b"])) - ); - addFiles( - files, - __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b", "c"])) - ); - - expect(files.size).toBe(2); -}); diff --git a/examples/runtime-specific-used-exports2/3.js b/examples/runtime-specific-used-exports2/3.js deleted file mode 100644 index 04c6871b6fa..00000000000 --- a/examples/runtime-specific-used-exports2/3.js +++ /dev/null @@ -1,40 +0,0 @@ -import { - b, - _2 -} from "./path2"; -import { - aUsed, - bUsed, - cUsed -} from "root1"; -import { - dUsed, - eUsed, - fUsed -} from "root2"; -import { addFiles, isSame } from "./helper"; - -// should be the same as 2.js and reuse defaultVendors -it("should use only current entrypoint exports", () => { - expect(b).toBe("b"); - expect(_2.f).toBe("f"); - expect(aUsed).toBe(false); - expect(bUsed).toBe(true); - expect(cUsed).toBe(false); - expect(dUsed).toBe(false); - expect(eUsed).toBe(false); - expect(fUsed).toBe(true); - - const files = new Set(); - - addFiles( - files, - __STATS__.chunks.filter(ch => isSame(ch.runtime, ["c"])) - ); - addFiles( - files, - __STATS__.chunks.filter(ch => isSame(ch.runtime, ["b", "c"])) - ); - - expect(files.size).toBe(2); -}); diff --git a/examples/runtime-specific-used-exports2/helper.js b/examples/runtime-specific-used-exports2/helper.js deleted file mode 100644 index 0263269dfa5..00000000000 --- a/examples/runtime-specific-used-exports2/helper.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * @template T - * @param {T[]} arr arr - * @param {T[]} expected expected - * @returns {boolean} is same - */ -export function isSame(arr, expected) { - const set = new Set(arr); - return expected.every(i => set.has(i)); -} - -/** - * @param {Set} files - * @param {{files: string[]}[]} chunks - */ -export function addFiles(files, chunks) { - chunks.forEach(ch => ch.files.forEach(f => files.add(f))); -} diff --git a/examples/runtime-specific-used-exports2/package.json b/examples/runtime-specific-used-exports2/package.json deleted file mode 100644 index 0318e20f9bb..00000000000 --- a/examples/runtime-specific-used-exports2/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "scripts":{ - "build": "rspack build", - "dev": "rspack dev" - }, - "devDependencies": { - "@rspack/core": "workspace:^" - } -} diff --git a/examples/runtime-specific-used-exports2/path1.js b/examples/runtime-specific-used-exports2/path1.js deleted file mode 100644 index 9ba7bd7c36e..00000000000 --- a/examples/runtime-specific-used-exports2/path1.js +++ /dev/null @@ -1,4 +0,0 @@ -import { _1, _2 } from "./reexport-all"; -import { e, d } from "root2"; - -export { _1, e }; diff --git a/examples/runtime-specific-used-exports2/path2.js b/examples/runtime-specific-used-exports2/path2.js deleted file mode 100644 index 37dcfbbddf0..00000000000 --- a/examples/runtime-specific-used-exports2/path2.js +++ /dev/null @@ -1,6 +0,0 @@ -import { _1 } from "./path1"; -import { _2 } from "./reexport-all"; - -const b = _1.b; - -export { b, _2 } diff --git a/examples/runtime-specific-used-exports2/reexport-all.js b/examples/runtime-specific-used-exports2/reexport-all.js deleted file mode 100644 index 4ef0128938e..00000000000 --- a/examples/runtime-specific-used-exports2/reexport-all.js +++ /dev/null @@ -1,2 +0,0 @@ -export * as _1 from "root1"; -export * as _2 from "root2"; diff --git a/examples/runtime-specific-used-exports2/rspack.config.js b/examples/runtime-specific-used-exports2/rspack.config.js deleted file mode 100644 index 3f0bcf0079a..00000000000 --- a/examples/runtime-specific-used-exports2/rspack.config.js +++ /dev/null @@ -1,25 +0,0 @@ -const rspack = require("@rspack/core"); -/**@type {import("@rspack/cli").Configuration}*/ -module.exports = { - output: { - filename: "[name].js" - }, - target: "node", - optimization: { - chunkIds: "named", - splitChunks: { - chunks: "all", - cacheGroups: { - defaultVendors: { - test: /[\\/]node_modules[\\/]/, - enforce: true - } - } - } - }, - entry: { - a: "./1", - b: "./2", - c: "./3" - } -}; diff --git a/examples/runtime-specific-used-exports2/test.config.js b/examples/runtime-specific-used-exports2/test.config.js deleted file mode 100644 index c5938acd51c..00000000000 --- a/examples/runtime-specific-used-exports2/test.config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - findBundle: function() { - return [ - "./a.js", - "./b.js", - "./c.js" - ]; - } -}; diff --git a/examples/runtime-specific-used-exports2/test.filter.js b/examples/runtime-specific-used-exports2/test.filter.js deleted file mode 100644 index 3be456dcd23..00000000000 --- a/examples/runtime-specific-used-exports2/test.filter.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = () => {return false} \ No newline at end of file diff --git a/examples/runtime-specific-used-exports2/webpack.config.js b/examples/runtime-specific-used-exports2/webpack.config.js deleted file mode 100644 index 0895dba239b..00000000000 --- a/examples/runtime-specific-used-exports2/webpack.config.js +++ /dev/null @@ -1,24 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - output: { - filename: "[name].js" - }, - target: "node", - optimization: { - chunkIds: "named", - splitChunks: { - chunks: "all", - cacheGroups: { - defaultVendors: { - test: /[\\/]node_modules[\\/]/, - enforce: true - } - } - } - }, - entry: { - a: "./1", - b: "./2", - c: "./3" - } -}; From 571188042aaec91825c3cb96a65e5d3057decd5a Mon Sep 17 00:00:00 2001 From: IWANABETHATGUY Date: Mon, 19 Feb 2024 21:29:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=F0=9F=A4=96=20recover?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 8 -------- .../cases/wasm/export-imported-global/test.filter.js | 2 +- .../runtime-specific-used-exports2/test.config.js | 1 - .../runtime-specific-used-exports2/test.filter.js | 2 +- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3d202bc1d7..e630e2ff161 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -248,14 +248,6 @@ importers: specifier: ^5.90.0 version: 5.90.0(@swc/core@1.3.23)(webpack-cli@4.10.0) - examples/basic: {} - - examples/runtime-specific-used-exports2: - devDependencies: - '@rspack/core': - specifier: workspace:^ - version: link:../../packages/rspack - npm/darwin-arm64: {} npm/darwin-x64: {} diff --git a/webpack-test/cases/wasm/export-imported-global/test.filter.js b/webpack-test/cases/wasm/export-imported-global/test.filter.js index c32d75292eb..23177349638 100644 --- a/webpack-test/cases/wasm/export-imported-global/test.filter.js +++ b/webpack-test/cases/wasm/export-imported-global/test.filter.js @@ -1,5 +1,5 @@ var supportsWebAssembly = require("../../../helpers/supportsWebAssembly"); module.exports = function(config) { - return false + return supportsWebAssembly(); }; diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js index 0b00d71ce8c..c5938acd51c 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.config.js @@ -1,6 +1,5 @@ module.exports = { findBundle: function() { - return [ "./a.js", "./b.js", diff --git a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js index 8e5c51af343..3be456dcd23 100644 --- a/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js +++ b/webpack-test/configCases/optimization/runtime-specific-used-exports2/test.filter.js @@ -1 +1 @@ -module.exports = () => {return true} +module.exports = () => {return false} \ No newline at end of file