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

dynamic import is importing dependencies multiple times #16006

Open
matteobertozzi opened this issue Dec 26, 2024 · 0 comments
Open

dynamic import is importing dependencies multiple times #16006

matteobertozzi opened this issue Dec 26, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@matteobertozzi
Copy link

What version of Bun is running?

1.1.42+50eec0025

What platform is your computer?

Darwin 24.2.0 arm64 arm

What steps can reproduce the bug?

3 simple projects:

  • my-lib contains an index.ts with a simple exported function myLibFunction()
  • my-dyn-lib contains an index.ts that calls myLibFunction() from my-lib
  • my-app contains an index.ts that calls myLibFunction() from my-lib and does an import('../my-dyn-lib/index.ts')

my-lib is imported a second time when importing(my-dyn-lib),
if another dyn-lib2 is added, my-lib is imported again

----> my-lib imported <----
Hello from my-app!
my-lib function called
----> my-lib imported <----
Hello from my-dyn-lib
my-lib function called

my-app and my-dyn-lib have a dependency on my-lib as "my-lib": "file:../my-lib/my-lib-1.0.0.tgz"
with my-lib being just a bun pm pack

NOTE that the double import does not happen if the package.json has "my-lib": "file:../my-lib/"

$ cd my-lib
$ bun pm pack
$ cd ../my-dyn-lib
$ bun install ../my-lib/my-lib-1.0.0.tgz
$ cd ../my-app
$ bun install ../my-lib/my-lib-1.0.0.tgz
$ bun run index.ts

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

import-twice.zip

@matteobertozzi matteobertozzi added bug Something isn't working needs triage labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant