chore: throw error when dllplugin needs to generate multiple manifest files but the path config is incorrect.

This commit is contained in:
cwj0417 2024-03-16 01:23:24 +08:00
parent e4fee1527b
commit 6b6ce2a4a8
5 changed files with 32 additions and 0 deletions

View File

@ -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, {

View File

@ -0,0 +1 @@
module.exports = "a";

View File

@ -0,0 +1 @@
module.exports = "b";

View File

@ -0,0 +1 @@
module.exports = [[/each chunk must have a unique path/]];

View File

@ -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"
)
})
]
};