Skip to content

Commit 609989c

Browse files
test: cover CleanPlugin and DotenvPlugin options validation
`output.clean` and `dotenv` apply their plugins after the validate hook has fired, so only a plugin instance in `plugins` validates its own options. No case did that, which left the precompiled checks uncovered. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPkbvwyRWt2SHgXDoYRdo
1 parent f5901e6 commit 609989c

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
it("should compile and run the test", function() {});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
const { CleanPlugin } = require("../../../../");
4+
5+
// Unlike `output.clean`, a plugin instance validates its own options
6+
/** @type {import("../../../../").Configuration} */
7+
module.exports = {
8+
plugins: [new CleanPlugin({ dry: true, keep: /keep/ })]
9+
};

‎test/configCases/plugins/dotenv-plugin/webpack.config.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
const path = require("path");
4+
const { DotenvPlugin } = require("../../../../");
45

56
/** @type {import("../../../../").Configuration[]} */
67
module.exports = [
@@ -61,5 +62,12 @@ module.exports = [
6162
dotenv: {
6263
template: [".env", ".env.myLocal", ".env.[mode]", ".env.[mode].myLocal"]
6364
}
65+
},
66+
// Test 8: Plugin instance - validates its own options, unlike `dotenv`
67+
{
68+
name: "plugin-instance",
69+
mode: "development",
70+
entry: "./basic.js",
71+
plugins: [new DotenvPlugin({ prefix: ["WEBPACK_"] })]
6472
}
6573
];

0 commit comments

Comments
 (0)