Implements the compat plugin #651
Merged
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.
What's the problem this PR addresses?
In order to improve the compatibility with third-party tools, we want to provide builtin patches to some high-values projects (the only one at this time being TypeScript). Those patches should be kept within their own plugins so that they don't leak within the Yarn codebase itself, and should stay minimal.
Ref #589
How did you fix it?
The
patch
plugin now supports a new hook calledgetBuiltinPatch
. This hook will get triggered when the patch specifier is of the formbuiltin<something>
, withsomething
being passed in parameter. The hook will then be able to return the adequate patch content.The core now supports a new hook called
reduceDescriptorAlias
. This hook will get triggered once for each unique dependency in the project, and is expected to return a new descriptor (either the original one, or a wrapper around the original one).A new plugin called
compat
implements both of these hooks: thetypescript
dependencies are converted intopatch:typescript@...#builtin<compat/typescript>
, which then applies the stock transform on the original TypeScript package.The script used to generate the
typescript
patchfile is currently stored within the compat package. It just requires to clone my TypeScript fork so thatmael/pnp
is available.