Skip to content

Commit

Permalink
fix: throw error when dll-plugin needs to generate multiple manifest …
Browse files Browse the repository at this point in the history
…files, but the path is the same.
  • Loading branch information
alexander-akait committed Mar 18, 2024
2 parents 7f1ad18 + 6b6ce2a commit 0bc85d1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/LibManifestPlugin.js
Expand Up @@ -53,6 +53,8 @@ class LibManifestPlugin {
},
(compilation, callback) => {
const moduleGraph = compilation.moduleGraph;
// store used paths to detect issue and output an error. #18200
const usedPaths = new Set();
asyncLib.forEach(
Array.from(compilation.chunks),
(chunk, callback) => {
Expand All @@ -64,6 +66,11 @@ class LibManifestPlugin {
const targetPath = compilation.getPath(this.options.path, {
chunk
});
if (usedPaths.has(targetPath)) {
callback(new Error(`each chunk must have a unique path`));
return;
}
usedPaths.add(targetPath);
const name =
this.options.name &&
compilation.getPath(this.options.name, {
Expand Down
1 change: 1 addition & 0 deletions test/configCases/dll-plugin/5-issue-18200/a.js
@@ -0,0 +1 @@
module.exports = "a";
1 change: 1 addition & 0 deletions test/configCases/dll-plugin/5-issue-18200/b.js
@@ -0,0 +1 @@
module.exports = "b";
1 change: 1 addition & 0 deletions test/configCases/dll-plugin/5-issue-18200/errors.js
@@ -0,0 +1 @@
module.exports = [[/each chunk must have a unique path/]];
22 changes: 22 additions & 0 deletions test/configCases/dll-plugin/5-issue-18200/webpack.config.js
@@ -0,0 +1,22 @@
var path = require("path");
var webpack = require("../../../../");

/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
a: "./a",
b: "./b"
},
output: {
filename: "MyDll.[name].js",
library: "[name]_[fullhash]"
},
plugins: [
new webpack.DllPlugin({
path: path.resolve(
__dirname,
"../../../js/config/dll-plugin/manifest_without_string_template.json"
)
})
]
};

0 comments on commit 0bc85d1

Please sign in to comment.