Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed May 1, 2024
1 parent 5203fbf commit 4a0b4f9
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/MultiCompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const asyncLib = require("neo-async");
const { SyncHook, MultiHook } = require("tapable");

const { defaultCacheName } = require("./config/defaults");
const ConcurrentCompilationError = require("./ConcurrentCompilationError");
const MultiStats = require("./MultiStats");
const MultiWatching = require("./MultiWatching");
Expand Down Expand Up @@ -127,19 +128,21 @@ module.exports = class MultiCompiler {
for (const compiler of this.compilers) {
if (compiler.options.cache && "name" in compiler.options.cache) {
const name = compiler.options.cache.name;
const warn = /__compiler(\d+)__$/.test(name);
if (warn) {
addWarning(
compiler,
new WebpackError(
`${
compiler.name
? `Compiler with name "${compiler.name}" doesn't use unique cache name. `
: ""
}Please set unique "cache.name" option.`
)
);
}
const match = /(.+)__compiler(\d+)__$/.exec(name);
// if there is no match it is unique name
if (!match || match[1] === defaultCacheName) continue;
addWarning(
compiler,
new WebpackError(
`${
compiler.name
? `Compiler with name "${compiler.name}" doesn't use unique cache name. `
: ""
}Please set unique "cache.name" option. Name "${
match[1]
}" already used.`
)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

// default settings. should just work

/** @type {import("../../../../").Configuration} */
module.exports = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

// no cache names

/** @type {import("../../../../").Configuration} */
module.exports = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
it("should build", () => {});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use strict";

// with explicit cache names

/** @type {import("../../../../").Configuration} */
module.exports = [
{
mode: "production",
entry: "./index",
cache: {
name: "filesystem",
type: "filesystem"
}
},
{
mode: "production",
entry: "./index",
cache: {
name: "filesystem",
type: "filesystem"
}
},
{
name: "3rd compiler",
mode: "production",
entry: "./index",
cache: {
name: "filesystem",
type: "filesystem"
}
}
];

0 comments on commit 4a0b4f9

Please sign in to comment.