nonara / ts-patch

Augment the TypeScript compiler to support extended functionality
MIT License
761 stars 26 forks source link

Not working on `yarn@v3` (berry) #119

Open samchon opened 1 year ago

samchon commented 1 year ago

image

https://github.com/samchon/ts-patch-yarn-v3/actions/runs/5781547560/job/15666822757#step:5:31

Tried to use ts-patch on yarn berry, but readonly problem be happened.

It does not occur runtime error, but patching be failed, so I think it is a bug.

AlCalzone commented 1 year ago

@samchon try the pnpm or node-modules linker. This works for me with yarn v3.

nonara commented 1 year ago

Hi @samchon! Let me know if AlCalzone's solution works for you, please.

I still haven't worked much with yarn3. We have tests in place but not turned on yet. I know others have said it works with the node modules linker.

If so, we should enable those tests and possibly add something to the readme.

tsengia commented 1 year ago

Don't know if this helps at all, but Yarn v3 has a yarn patch command that allows users to apply patches to installed packages locally: https://yarnpkg.com/cli/patch

This Yarn patch command utilizes the @yarnpkg/fslib library to access files stored inside of the installed .zip folders: https://yarnpkg.com/advanced/pnpapi#accessing-the-files

I'm not very familiar with this code base, but here's a potential idea:

  1. When ts-patch install is run, detect if Yarn Berry is in use.
  2. If it is in use, then utilize the same API calls that yarn patch uses to apply a patch to the typescript modules.
  3. Once patch is applied, perform the equivalent of a yarn patch-commit to update the package.json to resolve typescript to the patched version of typescript.

The yarn patch and yarn patch-commit commands are performed by the plugin-patch plugin.