You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
observe the instance of itty-router's Router is logged
What is the expected behavior?
bun is unable to resolve the dependency
What do you see instead?
I am able to use a dependency from package-b in package-a without declaring
Additional information
with pnpm npm packages will not be resolved if they are not declared as a dependency in the monorepo package
this is a mechanism to prevent the use of "phantom dependencies"
So let's consider why phantom dependencies are a problem. Imagine you depend on the parse-git package. parse-git depends on lodash, so since lodash is hoisted to the outermost node_modules, you can use lodash in your code without explicitly including it in your package.json. The problem arises the day the authors of parse-git decide that they no longer need lodash and remove the dependency ✂️ Now your code is going crash with a module not found error 💣 Even worse, if lodash is updated to a version with breaking changes, then your app may not crash, but suddenly start to misbehave in a difficult to debug manner. https://www.coana.tech/post/a-quick-introduction-to-phantom-dependencies
this is also helpful when onboarding new developers to a project, as they will not need to decipher what dependency is installing the phantom dependency used in the project's code
for example, when installing with bun my project structure is:
IMO it would be great if Bun defaulted to creating "safe" node_modules folders where only declared dependencies are resolvable like pnpm does. I don't see how flattening node_modules provides any useful benefit but it does introduce annoying and unnecessary problems.
What version of Bun is running?
0.7.3
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
bun install
bun run --cwd packages/package-a start
itty-router
's Router is loggedWhat is the expected behavior?
bun is unable to resolve the dependency
What do you see instead?
I am able to use a dependency from package-b in package-a without declaring
Additional information
with pnpm npm packages will not be resolved if they are not declared as a dependency in the monorepo package
this is a mechanism to prevent the use of "phantom dependencies"
this is also helpful when onboarding new developers to a project, as they will not need to decipher what dependency is installing the phantom dependency used in the project's code
for example, when installing with bun my project structure is:
however if I install using pnpm:
The text was updated successfully, but these errors were encountered: