peerDependencies not resolved when used with `bun link`
What version of Bun is running?
1.1.26+0a37423ba
What platform is your computer?
Linux 6.10.7-arch1-1 x86_64
What steps can reproduce the bug?
In a new folder, let's say /tmp/demo/pkg1, create a package: bun init
add a peerDependency that you import somewhere in your source file and bun install
run bun link
In a new folder, let's say /tmp/demo/pkg2, create a 2nd package: bun init
add your 1st package with bun link
add your peer dependency to the 2nd package.
run bun install
somewhere in your source files, import the 1st package.
See that the 1st package wont be able to resolve the peer dependecy since it's trying to resolve it from its own node_modules folder. However the dependency is installed in the node_modules folder from the 2nd package and symlinks are resolved to the actual paths.
What is the expected behavior?
pkg1 should be able to use the peer dependency installed in pkg2.
What do you see instead?
pkg1 can not find the peer dependency since it is simply linked and links will resolve to the physical (unrelated) paths.
Additional information
- Afair npm also had that problem at some point, but fixed it with the
--preserve-symlinksflag for node. - maybe
bun install --backend copyfilewould fix this, however at the cost of copying all dependencies - I suggest to use copyfile for peer dependencies by default or maybe if stated so in some kind of config (i.e. new field in
peerDependenciesMeta.<dependency>.copyfile: true) or some setting in the bunfig.toml
Just bumped into this again and unfortunately it's the kind of issue that makes bun link completely unusable for packages with peerDependencies.
I will resort to shipping beta packages to npm registry.