Repository navigation
perf: pass a precompiled options check to getOptions - #625
Conversation
Generate src/options.check.js with `schema-utils precompile --minify` and pass it to `this.getOptions`. Valid options then skip loading and compiling the schema on webpack versions that accept the check; older webpack ignores it.
🦋 Changeset detectedLatest commit: 67977d4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #625 +/- ##
=======================================
Coverage 96.93% 96.93%
=======================================
Files 2 2
Lines 652 653 +1
=======================================
+ Hits 632 633 +1
Misses 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review. WalkthroughThe loader now passes a generated options validator to Merge Risk:
|
Summary
this.getOptions(schema)makes webpack loadschema-utilsand compile the options schema with ajv on the loader's first call. webpack 5.113.0 accepts a check precompiled from the schema,this.getOptions(schema, check). When the check passes, webpack skips the schema entirely.src/options.check.jsis generated byschema-utils precompile --minify src/options.json. It is an ES module, and babel builds it into bothdist/esmanddist/cjs.lint:schemafails when the check is out of date, andfix:schemaregenerates it as part ofnpm run fix.schema-utils^4.8.5 is added as a devDependency, and thewebpackdevDependency is bumped to ^5.113.0.less-loaderoptionsInvalid options still get the full
schema-utilsvalidation, so the error messages are unchanged.Tests
test/validate-options.test.js, the check must agree with the schema on every value, and values that are not an object never pass it.dist/cjsanddist/esmwith valid and invalid options. Valid options compile without loading ajv, and invalid options give the sameValidationError.unknownoption snapshots changed only becauseschema-utils4.8.5, which webpack 5.113.0 brings, prints the types of boolean properties.Breaking change
No. The
webpackpeer range is unchanged. Older webpack versions and rspack ignore the extra argument and validate against the schema as before.Generated by Claude Code
Summary by CodeRabbit