diff --git a/lib/LibManifestPlugin.js b/lib/LibManifestPlugin.js index 527231aa48a..a718b6c86d2 100644 --- a/lib/LibManifestPlugin.js +++ b/lib/LibManifestPlugin.js @@ -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) => { @@ -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, { diff --git a/test/configCases/dll-plugin/5-issue-18200/a.js b/test/configCases/dll-plugin/5-issue-18200/a.js new file mode 100644 index 00000000000..6cd1d0075d4 --- /dev/null +++ b/test/configCases/dll-plugin/5-issue-18200/a.js @@ -0,0 +1 @@ +module.exports = "a"; diff --git a/test/configCases/dll-plugin/5-issue-18200/b.js b/test/configCases/dll-plugin/5-issue-18200/b.js new file mode 100644 index 00000000000..dfbbeb621fa --- /dev/null +++ b/test/configCases/dll-plugin/5-issue-18200/b.js @@ -0,0 +1 @@ +module.exports = "b"; diff --git a/test/configCases/dll-plugin/5-issue-18200/errors.js b/test/configCases/dll-plugin/5-issue-18200/errors.js new file mode 100644 index 00000000000..48720d5cbae --- /dev/null +++ b/test/configCases/dll-plugin/5-issue-18200/errors.js @@ -0,0 +1 @@ +module.exports = [[/each chunk must have a unique path/]]; diff --git a/test/configCases/dll-plugin/5-issue-18200/webpack.config.js b/test/configCases/dll-plugin/5-issue-18200/webpack.config.js new file mode 100644 index 00000000000..d88fb4399f6 --- /dev/null +++ b/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" + ) + }) + ] +};