pdcl-15166: fix ajv hoist issue for non-node environments#25
Draft
brenthosie wants to merge 1 commit into
Draft
Conversation
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.
Description
ajv is already a regular dependency of reactor-validator (not a peer dep), npm guarantees it gets installed nested under node_modules/@adobe/reactor-validator/node_modules/ajv.
If validateSchema.js does require('ajv/dist/core') directly instead of going through ajv-draft-04, that require resolves relative to reactor-validator's own location — finding the nested ajv@8 correctly, regardless of what version of ajv the consumer has at their top level.
The indirection through ajv-draft-04 is what breaks things: it's a separately-hoisted package with its own (broken) resolution scope. Cutting it out means the ajv require never leaves reactor-validator's own module boundary.
Related Issue
https://jira.corp.adobe.com/browse/PDCL-15166
Motivation and Context
When attempting to integrate reactor-validator into Lens, the Lens project needed to install ajv8 as a direct dependency even though the project doesn't use it outside of calling reactor-validator.
How Has This Been Tested?
New tests added to test that we are draft 4 compliant in reactor-validator.
Screenshots (if appropriate):
Types of changes
Checklist: