antfu-collective / local-pkg

Get information on local packages.
MIT License
143 stars 14 forks source link

Yarn PnP support #2

Open NMinhNguyen opened 2 years ago

NMinhNguyen commented 2 years ago

I'm trying to use Vitest and I'm running into an issue with Yarn PnP:

.pnp.cjs:101340 Uncaught Error: local-pkg tried to access vite, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: vite (via "vite/package.json") Required by: local-pkg@npm:0.4.0 (via /Users/minh/dev/project/.yarn/cache/local-pkg-npm-0.4.0-c31827f33b-46964cea4b.zip/node_modules/local-pkg/)

I believe that this package needs to support basedir (similar to resolve), and set the paths option of require.resolve:

https://github.com/antfu/local-pkg/blob/fc9d06c5a43485d83f41ec35dfc842e1f6d45aa5/index.mjs#L51-L65

TeemuKoivisto commented 1 year ago

Yes this is still an issue. Is there an easy fix for this?

sirganya commented 1 year ago

bump

JoshuaKGoldberg commented 1 year ago

This also happens with pnpm: https://github.com/vitest-dev/vitest/issues/3112.

francoisauclair911 commented 3 months ago

bump

wojtekmaj commented 1 day ago

FYI - Vitest no longer uses local-pkg as of version 2.0.0, and therefore, PnP issues are also gone.