Skip to content

Implements the compat plugin #651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 27, 2019
Merged

Implements the compat plugin #651

merged 6 commits into from
Dec 27, 2019

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Dec 27, 2019

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 called getBuiltinPatch. This hook will get triggered when the patch specifier is of the form builtin<something>, with something 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: the typescript dependencies are converted into patch: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 that mael/pnp is available.

@arcanis arcanis merged commit c428aee into master Dec 27, 2019
@orta
Copy link
Contributor

orta commented Jan 15, 2020

I like it, it's a miniature copy of patch-package in Yarn :D

@arcanis arcanis deleted the mael/patch-resolution branch January 17, 2020 11:07
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