Skip to content

Commit 105b76f

Browse files
fix: accept a file:// prefix in an absolute path (#49)
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`. Co-authored-by: Claude <noreply@anthropic.com>
1 parent dfc42a9 commit 105b76f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

precompile-schemas/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ const processJson = processSchema.bind(null, {
128128

129129
const postprocess = async (code) => {
130130
// add hoisted values
131+
// Keep in sync with the `absolutePath` keyword of `schema-utils`, the
132+
// pre-compiled schema has to accept exactly what the real one accepts
131133
if (/absolutePathRegExp/.test(code))
132-
code = `const absolutePathRegExp = /^(?:[A-Za-z]:[\\\\/]|\\\\\\\\|\\/)/;${code}`;
134+
code = `const absolutePathRegExp = /^(?:file:\\/\\/)?(?:[A-Za-z]:[\\\\/]|\\\\\\\\|\\/)/;${code}`;
133135

134136
// remove unnecessary error code:
135137
code = code

0 commit comments

Comments
 (0)