Skip to content

fix: Build crashing when the consumer has more than 1 resolved versions of ajv package - #1644

Open
d3xter666 wants to merge 1 commit into
mainfrom
fork-ajv-errors
Open

d3xter666 wants to merge 1 commit into
mainfrom
fork-ajv-errors

Conversation

@d3xter666

Copy link
Copy Markdown
Member

JIRA: CPOUI5FOUNDATION-1374
Upport of: SAP/ui5-project#887

@ui5/project registers the ajv-errors plugin on its Ajv instance, but ajv-errors imports its own copy of ajv at load time instead of using the instance it's given. When a consumer's tree has two ajv copies, the two bind to different module instances, AJV's instanceof-based codegen breaks, and ui5 build crashes (SyntaxError: Unexpected token ':' — see ajv-validator/ajv-errors#157). We can't fix this from the consumer side since @ui5/project is itself a dependency.

Vendoring ajv-errors inside @ui5/project makes its require("ajv") resolve to the same ajv that validator.js uses — one module instance, so the mismatch can't happen regardless of the consumer's dependency tree. Follows the existing serve-index fork precedent; temporary until upstream lets consumers inject ajv.

…ns of ajv package

JIRA: CPOUI5FOUNDATION-1374
Upport of: SAP/ui5-project#887

`@ui5/project` registers the `ajv-errors` plugin on its `Ajv` instance, but `ajv-errors` imports its **own** copy of `ajv` at load time instead of using the instance it's given. When a consumer's tree has two `ajv` copies, the two bind to different module instances, AJV's `instanceof`-based codegen breaks, and `ui5 build` crashes (`SyntaxError: Unexpected token ':'` — see [ajv-validator/ajv-errors#157](ajv-validator/ajv-errors#157)). We can't fix this from the consumer side since `@ui5/project` is itself a dependency.

Vendoring `ajv-errors` **inside** `@ui5/project` makes its `require("ajv")` resolve to the **same `ajv`** that `validator.js` uses — one module instance, so the mismatch can't happen regardless of the consumer's dependency tree. Follows the existing `serve-index` fork precedent; temporary until upstream lets consumers inject `ajv`.
@d3xter666
d3xter666 marked this pull request as draft October 8, 2026 14:24
@d3xter666
d3xter666 marked this pull request as ready for review October 8, 2026 14:46
@d3xter666
d3xter666 requested a review from a team October 8, 2026 14:46

This branch has not been deployed

No deployments
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.

1 participant