-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only register
SplitChunkPlugin
once (#4766)
- Loading branch information
Showing
14 changed files
with
94 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import assert from "assert"; | ||
import { toRawSplitChunksOptions } from "../config/adapter"; | ||
import { type OptimizationSplitChunksOptions } from "../config/zod"; | ||
import { BuiltinPluginName, create } from "./base"; | ||
|
||
export const SplitChunksPlugin = create( | ||
BuiltinPluginName.SplitChunksPlugin, | ||
(options: OptimizationSplitChunksOptions) => { | ||
let raw = toRawSplitChunksOptions(options); | ||
assert(typeof raw !== "undefined"); | ||
return raw; | ||
} | ||
); | ||
|
||
export const OldSplitChunksPlugin = create( | ||
BuiltinPluginName.SplitChunksPlugin, | ||
(options: OptimizationSplitChunksOptions) => { | ||
let raw = toRawSplitChunksOptions(options); | ||
assert(typeof raw !== "undefined"); | ||
return raw; | ||
} | ||
); |
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
3 changes: 3 additions & 0 deletions
3
packages/rspack/tests/configCases/chunk-loading/issue-4754/child-entry.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,3 @@ | ||
it("should never run this file because child compiler only compile not emit", () => { | ||
expect(1).toBe(2); | ||
}); |
3 changes: 3 additions & 0 deletions
3
packages/rspack/tests/configCases/chunk-loading/issue-4754/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,3 @@ | ||
it("should build success", () => { | ||
expect(1).toBe(1); | ||
}); |
28 changes: 28 additions & 0 deletions
28
packages/rspack/tests/configCases/chunk-loading/issue-4754/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,28 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
plugins: [ | ||
{ | ||
apply(compiler) { | ||
compiler.hooks.make.tap("make", compilation => { | ||
const childEntry = path.resolve(__dirname, "./child-entry.js"); | ||
const childCompiler = compilation.createChildCompiler("name", {}, [ | ||
new compiler.webpack.EntryPlugin(compiler.context, childEntry) | ||
]); | ||
childCompiler.compile(() => {}); | ||
}); | ||
} | ||
} | ||
], | ||
optimization: { | ||
splitChunks: { | ||
cacheGroups: { | ||
singleVendor: { | ||
chunks: "all", | ||
enforce: true, | ||
name: "vendor" | ||
} | ||
} | ||
} | ||
} | ||
}; |