fix: accept a file:// prefix in an absolute path - #49
Merged
Conversation
The pre-compiled schemas hoist their own copy of the regexp the `absolutePath` keyword of `schema-utils` uses. `schema-utils` 4.4.0 accepts an optional `file://` prefix, so a path from `import.meta.resolve()` can be passed to an option that takes an absolute path, and this copy has to accept it too. While the two disagree, the pre-compiled schema rejects a value the real one accepts, which makes webpack fall back to the real schema on every validation and warn `DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID`.
|
alexander-akait
added a commit
to webpack/webpack
that referenced
this pull request
Sep 10, 2026
It accepts a `file://` prefix where an option takes an absolute path, the half of this change that lives in the validator. The pre-compiled schema still rejects one until `tooling` ships the same regexp (webpack/tooling#49 is merged and waits on a tag), so the `file-url-condition` case stays gated until that bump. Its messages name the type of an object's properties now, which moves the validation snapshots, e.g. `object { apply, … }` reads `object { apply: function, … }`. `yarn upgrade` also normalized the indentation of two `scripts` entries.
alexander-akait
added a commit
to webpack/webpack
that referenced
this pull request
Sep 10, 2026
It accepts a `file://` prefix where an option takes an absolute path, the half of this change that lives in the validator. The pre-compiled schema still rejects one until `tooling` ships the same regexp (webpack/tooling#49 is merged and waits on a tag), so the `file-url-condition` case stays gated until that bump. Its messages name the type of an object's properties now, which moves the validation snapshots, e.g. `object { apply, … }` reads `object { apply: function, … }`. `yarn upgrade` also normalized the indentation of two `scripts` entries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Needed by webpack/webpack#22012.
precompile-schemashoists its own copy of the regexp that theabsolutePathkeyword ofschema-utilsuses:schema-utils4.4.0 (webpack/schema-utils#222) accepts an optionalfile://prefix, so a path fromimport.meta.resolve()can be passed to an option that takes an absolute path. This copy has to accept the same thing.While the two disagree, the pre-compiled schema rejects a value the real schema accepts. webpack notices and falls back to the real schema, so the value still works, but every validation pays for it and it warns:
Verification
The emitted regexp was compared against the one in
schema-utils4.4.0 (/^(?:file:\/\/)?(?:[A-Za-z]:(\\|\/)|\\\\|\/)/) over both accepted and rejected inputs —file:///dir,file://C:/dir,/dir,C:\dir,C:/dir,\\server\share,./rel,rel,"",filet:///dir— and they agree on every one, so nothing that used to be rejected becomes accepted apart from thefile://prefix itself.Regenerating webpack's schemas with this change makes its pre-compiled validator accept
context: "file:///directory", un-skips theconfigCases/rule-set/file-url-conditioncase in webpack#22012 (4 tests, all passing) and removes the deprecation warning above.yarn lintpasses.A new tag is needed after this lands, so webpack can bump
toolingand regenerate.🤖 Generated with Claude Code
https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK
Generated by Claude Code