Skip to content

Commit f5901e6

Browse files
perf: validate CleanPlugin and DotenvPlugin options with a precompiled check
Both plugins were the only ones in lib/ still calling compiler.validate without a check, so valid options compiled their schema with ajv on every start. The schemas are published from their WebpackOptions definitions and compiled by tooling/precompile-schemas.js like the others. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QYPkbvwyRWt2SHgXDoYRdo
1 parent e1c10dc commit f5901e6

8 files changed

Lines changed: 35 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Validate `CleanPlugin` and `DotenvPlugin` options with a precompiled check, so valid options no longer compile their schema at startup.

‎declarations/WebpackOptions.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export type Clean = boolean | CleanOptions;
300300

301301
/**
302302
* Advanced options for cleaning assets.
303+
* @publishes plugins/output/CleanOptions
303304
*/
304305
export interface CleanOptions {
305306
/**
@@ -904,6 +905,7 @@ export type Dotenv =
904905

905906
/**
906907
* Options for Dotenv plugin.
908+
* @publishes plugins/define/DotenvPluginOptions
907909
*/
908910
export interface DotenvPluginOptions {
909911
/**

‎lib/define/DotenvPlugin.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ class DotenvPlugin {
281281
{
282282
name: "Dotenv Plugin",
283283
baseDataPath: "options"
284-
}
284+
},
285+
(options) =>
286+
require("../../schemas/plugins/define/DotenvPluginOptions.check")(
287+
options
288+
)
285289
);
286290
});
287291
const definePlugin = new compiler.webpack.DefinePlugin({});

‎lib/output/CleanPlugin.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ class CleanPlugin {
374374
{
375375
name: "Clean Plugin",
376376
baseDataPath: "options"
377-
}
377+
},
378+
(options) =>
379+
require("../../schemas/plugins/output/CleanOptions.check")(options)
378380
);
379381
});
380382

‎schemas/plugins/define/DotenvPluginOptions.check.js‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$ref": "../../WebpackOptions.json#/definitions/DotenvPluginOptions"
3+
}

‎schemas/plugins/output/CleanOptions.check.js‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$ref": "../../WebpackOptions.json#/definitions/CleanOptions"
3+
}

0 commit comments

Comments
 (0)