Skip to content
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

esbuild creates node_modules/.cache directory in Yarn PnP repo #2685

Closed
jlvandenhout opened this issue Nov 20, 2022 · 4 comments
Closed

esbuild creates node_modules/.cache directory in Yarn PnP repo #2685

jlvandenhout opened this issue Nov 20, 2022 · 4 comments

Comments

@jlvandenhout
Copy link

jlvandenhout commented Nov 20, 2022

When I create a Yarn PnP repo and install or run esbuild, it creates a node_modules/.cache/esbuild directory containing pnpapi-esbuild-linux-64-0.15.14-esbuild, even after deleting the directory. Shouldn't it just be able to use Yarn PnP directly?

Steps to reproduce:

  1. mkdir test && cd test
  2. yarn init && yarn add --dev esbuild
$ ls .yarn/cache
esbuild-linux-64-npm-0.15.14-45bb2717bc-8.zip  esbuild-npm-0.15.14-0f40bc75be-3e09ddca1f.zip
$ ls node_modules/.cache/esbuild/
pnpapi-esbuild-linux-64-0.15.14-esbuild

Versions used:

  • Linux kernel 5.10.16.3-microsoft-standard-WSL2
  • Yarn 3.2.4
  • esbuild 0.15.14
@evanw
Copy link
Owner

evanw commented Nov 20, 2022

This is needed because esbuild’s package has to run an executable but Yarn sticks everything in zip files, and the OS can’t run an executable when it’s in a zip file. Yarn’s official documentation says to use this folder instead of using esbuild’s package directory, so esbuild is just doing what it’s supposed to do according to the Yarn maintainers: https://yarnpkg.com/advanced/rulebook#packages-should-never-write-inside-their-own-folder-outside-of-postinstall.

@jlvandenhout
Copy link
Author

All clear, thanks for the explanation!

@evanw
Copy link
Owner

evanw commented Nov 20, 2022

An alternative is for esbuild to tell Yarn to not put esbuild’s packages in zip files. Then esbuild will take up more space on the file system in some cases, but shouldn’t need to create a folder to put the executable in like this. I should probably do that because this isn’t the first time people have complained about this.

@jlvandenhout
Copy link
Author

Since esbuild is mostly used as dev dependency anyway, I think the extra space wouldn't matter too much. In any case, thank you for the explanations and considerations. You can consider this closed if you want 👍

@evanw evanw closed this as completed in 4b1200f Nov 21, 2022
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

No branches or pull requests

2 participants