-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: splitChunks.cacheGroups.filename supports function (#8779)
- Loading branch information
Showing
16 changed files
with
94 additions
and
16 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
24 changes: 24 additions & 0 deletions
24
packages/rspack-test-tools/tests/configCases/split-chunks/custom-filename-function/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,24 @@ | ||
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", () => { | ||
const files = require("fs").readdirSync(__dirname); | ||
expect(files).toContain("a.js"); | ||
expect(files).toContain("b.js"); | ||
expect(files).toContain("common-common1_js.js"); | ||
expect(files).toContain("common-common2_js.js"); | ||
expect(files).toContain("common-common3_js.js"); | ||
expect(files).toContain("shared-shared-shared1_js.js"); | ||
expect(files).toContain("shared-shared-shared2_js.js"); | ||
}); |
5 changes: 5 additions & 0 deletions
5
packages/rspack-test-tools/tests/configCases/split-chunks/custom-filename-function/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.
34 changes: 34 additions & 0 deletions
34
...spack-test-tools/tests/configCases/split-chunks/custom-filename-function/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,34 @@ | ||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
mode: "development", | ||
entry: { | ||
a: "./a", | ||
b: "./b" | ||
}, | ||
output: { | ||
filename: "[name].js", | ||
libraryTarget: "commonjs2" | ||
}, | ||
optimization: { | ||
chunkIds: "named", | ||
splitChunks: { | ||
cacheGroups: { | ||
shared: { | ||
chunks: "all", | ||
test: /shared/, | ||
filename: (pathData, assetInfo) => { | ||
expect(pathData).toBeDefined() | ||
expect(typeof assetInfo).toBe('object') | ||
return "shared-[name].js" | ||
}, | ||
enforce: true | ||
}, | ||
common: { | ||
chunks: "all", | ||
test: /common/, | ||
enforce: true | ||
} | ||
} | ||
} | ||
} | ||
}; |
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions
6
.../rspack-test-tools/tests/configCases/split-chunks/custom-filename-function/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