patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

Yarn vendored packages impossible to patch

Open corporateuser opened this issue 1 year ago • 2 comments

Hello, we have packages provided to us through private repository, the package itself is not owned by us. We add this with "file:" protocol of yarn:

{
  "dependencies": {
    "shim": "file:./vendor/shim-0.1.23.tgz" 
  }
}

When we try to patch this package with yarn patch-package shim it returns the following error: error Package "" refers to a non-existing file '"/private/var/folders/kh/kgqx507n5b31w3676tsvkw3r0000gn/T/tmp-2705AUL26tJlAvfk/vendor/shim-0.1.23.tgz#73c29517ef20deb521e83f38b931a7d09fabdfbc"'.

I've managed to overcome this issue manually, with:

  1. put a breakpoint to line which corresponds to https://github.com/ds300/patch-package/blob/fbbeccd3025451d862b2b8786215e8fd111bec5a/src/makePatch.ts#L109
  2. Run vscode in debug mode, so breakpoint would trigger
  3. copy "vendor" folder to the tmpRepoNpmRoot
  4. edit package.json file in tmpRepoNpmRoot to remove this fancy ending #73c29517ef20deb521e83f38b931a7d09fabdfbc
  5. continue execution

So, for yarn managed projects we need to copy files itself along with package.json creation. Could this be implemented in patch-package itself?

corporateuser avatar Mar 30 '23 12:03 corporateuser

Not sure if related, but I have a vendored package in resolutions field and it makes it possible to patch any packages. I can try to patch package A and it will complain about not being able to find vendored package B which is completely unrelated.

alex-kinokon avatar Jun 10 '23 23:06 alex-kinokon

I've tried resolutions and it still fails with file not found.

corporateuser avatar Jul 18 '23 09:07 corporateuser