Skip to content

fix: accept a file:// prefix in an absolute path - #49

Merged
alexander-akait merged 1 commit into
mainfrom
fix/absolute-path-file-url
Sep 8, 2026
Merged

fix: accept a file:// prefix in an absolute path#49
alexander-akait merged 1 commit into
mainfrom
fix/absolute-path-file-url

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Needed by webpack/webpack#22012.

precompile-schemas hoists its own copy of the regexp that the absolutePath keyword of schema-utils uses:

code = `const absolutePathRegExp = /^(?:[A-Za-z]:[\\\\/]|\\\\\\\\|\\/)/;${code}`;

schema-utils 4.4.0 (webpack/schema-utils#222) accepts an optional file:// prefix, so a path from import.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:

[DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID] DeprecationWarning: webpack bug:
Pre-compiled schema reports error while real schema is happy.
This has performance drawbacks.

Verification

The emitted regexp was compared against the one in schema-utils 4.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 the file:// prefix itself.

Regenerating webpack's schemas with this change makes its pre-compiled validator accept context: "file:///directory", un-skips the configCases/rule-set/file-url-condition case in webpack#22012 (4 tests, all passing) and removes the deprecation warning above.

yarn lint passes.

A new tag is needed after this lands, so webpack can bump tooling and regenerate.

🤖 Generated with Claude Code

https://claude.ai/code/session_013wqLmVHkAGBsWQgXknEQCK


Generated by Claude Code

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`.
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@alexander-akait
alexander-akait merged commit 105b76f into main Sep 8, 2026
8 of 9 checks passed
@alexander-akait
alexander-akait deleted the fix/absolute-path-file-url branch September 8, 2026 16:53
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants