-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split chunks overall filename (#9243)
- Loading branch information
Showing
16 changed files
with
143 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/rspack-test-tools/tests/configCases/split-chunks/custom-filename-overall/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import "./shared1"; | ||
import "./common1"; | ||
|
||
it("should be able to load the split chunk on demand (shared)", () => { | ||
return import(/* webpackChunkName: "theName" */ "./shared2"); | ||
}); | ||
|
||
it("should be able to load the split chunk on demand (common)", () => { | ||
return Promise.all([ | ||
import(/* webpackChunkName: "otherName1" */ "./common2"), | ||
import(/* webpackChunkName: "otherName2" */ "./common3") | ||
]); | ||
}); | ||
|
||
it("should have files", async () => { | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const files = await fs.promises.readdir(__dirname); | ||
expect(files).toContain("shared-shared-shared1_js.js"); | ||
expect(files).toContain("shared-shared-shared2_js.js"); | ||
expect(files).toContain("splitted-chunks"); | ||
const innerFiles = await fs.promises.readdir(path.resolve(__dirname, "splitted-chunks")); | ||
expect(innerFiles).toContain("common-common1_js.js"); | ||
expect(innerFiles).toContain("common-common2_js.js"); | ||
expect(innerFiles).toContain("common-common3_js.js"); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/rspack-test-tools/tests/configCases/split-chunks/custom-filename-overall/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import "./shared1"; | ||
import "./shared2"; | ||
import "./common1"; | ||
import "./common2"; | ||
import "./common3"; |
Empty file.
Empty file.
Empty file.
31 changes: 31 additions & 0 deletions
31
...rspack-test-tools/tests/configCases/split-chunks/custom-filename-overall/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
mode: "development", | ||
entry: { | ||
a: "./a", | ||
b: "./b" | ||
}, | ||
output: { | ||
filename: "[name].js", | ||
libraryTarget: "commonjs2" | ||
}, | ||
optimization: { | ||
chunkIds: "named", | ||
splitChunks: { | ||
filename: "splitted-chunks/[name].js", | ||
cacheGroups: { | ||
shared: { | ||
chunks: "all", | ||
test: /shared/, | ||
filename: "shared-[name].js", | ||
enforce: true | ||
}, | ||
common: { | ||
chunks: "all", | ||
test: /common/, | ||
enforce: true | ||
} | ||
} | ||
} | ||
} | ||
}; |
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions
6
...s/rspack-test-tools/tests/configCases/split-chunks/custom-filename-overall/test.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import("../../../..").TConfigCaseConfig} */ | ||
module.exports = { | ||
findBundle: function (i, options) { | ||
return ["a.js"]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d688f4d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
d688f4d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ecosystem CI detail: Open