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

Bun subpaths imports are not resolved properly #3043

Open
p9f opened this issue Jan 27, 2025 · 0 comments
Open

Bun subpaths imports are not resolved properly #3043

p9f opened this issue Jan 27, 2025 · 0 comments

Comments

@p9f
Copy link

p9f commented Jan 27, 2025

Environment

  • nitro: 2.10.4
  • bun: 1.2
  • @clerk/backend: 1.23.7

Reproduction

https://github.com/p9f/nitro-clerk-bun-repro

Describe the bug

It seems that one can't install @clerk/backend on a bun + nitro server.
It fails with the error:

[nitro] [request error] [unhandled] Cannot find package '#crypto' from '/Users/p9f/repos/p9f/nitro-clerk-bun-repro/.output/server/node_modules/@clerk/backend/dist/chunk-G4VEKB6A.mjs'

My understanding is:

  • clerk use a subpath imports for their crypto code (package.json)
  • at build time, nitro is using the worker key to get the file path -> ./dist/runtime/browser/crypto.mjs
    • this is what i figured playing with the different value, but it seems consistent with the bun preset config (here): since bun is not defined, worker is next in line.
  • at run time, bun is using the node.imports key to get the file path -> ./dist/runtime/node/crypto.mjs, which causes the issue.
    • it seems consistent with this section of their documentation.

We could remove the worker item of the bun preset exportConditions (which would fix the issue) - but i am unsure about the implications.
This happened with @clerk/backend, but i am assuming it would be the case with any other dependency using a subpath imports.

Additional context

No response

Logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant