-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new_split_chunks): support
reuseExistingChunk
(#3000)
* feat(new_split_chunks): support `reuseExistingChunk` * Fix * Fix
- Loading branch information
Showing
17 changed files
with
222 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rspack/binding": patch | ||
--- | ||
|
||
feat(new_split_chunks): support `reuseExistingChunk` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#![feature(map_many_mut)] | ||
#![feature(let_chains)] | ||
|
||
pub(crate) mod cache_group; | ||
pub(crate) mod common; | ||
|
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
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/split-chunks/disable-reuse-existing-chunk-simple/foo-2.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 @@ | ||
export default "foo-2.js"; |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/split-chunks/disable-reuse-existing-chunk-simple/foo.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,2 @@ | ||
import "./foo-2"; | ||
export default "foo.js"; |
11 changes: 11 additions & 0 deletions
11
packages/rspack/tests/configCases/split-chunks/disable-reuse-existing-chunk-simple/index.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,11 @@ | ||
() => import("./foo"); | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export default "index.js"; | ||
|
||
it("disable-reuse-existing-chunk-simple", () => { | ||
expect(fs.existsSync(path.resolve(__dirname, "./splittedFoo.js"))).toBe(true); | ||
expect(fs.existsSync(path.resolve(__dirname, "./foo_js.js"))).toBe(false); | ||
}); |
24 changes: 24 additions & 0 deletions
24
...pack/tests/configCases/split-chunks/disable-reuse-existing-chunk-simple/webpack.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,24 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "node", | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
entry: "./index.js", | ||
experiments: { | ||
newSplitChunks: true | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
minSize: 1, | ||
cacheGroups: { | ||
splittedFoo: { | ||
name: "splittedFoo", | ||
test: /(foo|foo-2)\.js/, | ||
priority: 0, | ||
reuseExistingChunk: false | ||
} | ||
} | ||
} | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/rspack/tests/configCases/split-chunks/reuse-existing-chunk-simple/foo-2.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 @@ | ||
export default "foo-2.js"; |
2 changes: 2 additions & 0 deletions
2
packages/rspack/tests/configCases/split-chunks/reuse-existing-chunk-simple/foo.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,2 @@ | ||
import "./foo-2"; | ||
export default "foo.js"; |
13 changes: 13 additions & 0 deletions
13
packages/rspack/tests/configCases/split-chunks/reuse-existing-chunk-simple/index.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,13 @@ | ||
() => import("./foo"); | ||
|
||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
export default "index.js"; | ||
|
||
it("reuse-existing-chunk-simple", () => { | ||
expect(fs.existsSync(path.resolve(__dirname, "./splittedFoo.js"))).toBe( | ||
false | ||
); | ||
expect(fs.existsSync(path.resolve(__dirname, "./foo_js.js"))).toBe(true); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/rspack/tests/configCases/split-chunks/reuse-existing-chunk-simple/webpack.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,24 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "node", | ||
entry: "./index.js", | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
experiments: { | ||
newSplitChunks: true | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
minSize: 1, | ||
cacheGroups: { | ||
splittedFoo: { | ||
name: "splittedFoo", | ||
test: /(foo|foo-2)\.js/, | ||
priority: 0, | ||
reuseExistingChunk: true | ||
} | ||
} | ||
} | ||
} | ||
}; |