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
When trying to run NextJS with Turbopack on bun, the direct import of bun-specific APIs does not work - but a namespaced import works, if the interfaces are exposed (kudos to @MichalBastrzyk). The Turbopack-Team already knows about this: vercel/next.js#75220
// broken if turbopack is involved
// import { sql } from "bun";
$ bun --bun run node_modules/.bin/next dev --turbopack
[...]
○ Compiling /seed ...
✓ Compiled /seed in 687ms
⨯ ./app/seed/route.ts:2:1
Module not found: Can't resolve 'bun'
1 | import bcrypt from "bcrypt";
> 2 | import { sql, TransactionSQL } from "bun";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
Namespaced version:
// works with sql, since it's exposed in the type definition fileconstsql=newBun.SQL();// does NOT workconstTransactionSQL=Bun.TransactionSQL;
While this should be in general solved in turbopack (AFAIK), it would be nice to have a proper workaround for bun.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
Bun.TransactionSQL isn't a thing in bun, looks like it is an interface in the types though.
You can do transactions like this though:
awaitsql.begin(asynctx=>{// All queries in this function run in a transactionawaittx`INSERT INTO users (name) VALUES (${"Alice"})`;awaittx`UPDATE accounts SET balance = balance - 100 WHERE user_id = 1`;// Transaction automatically commits if no errors are thrown// Rolls back if any error occurs});
What version of Bun is running?
1.2.4+fd9a5ea66
What platform is your computer?
Linux 6.6.74-1-MANJARO x86_64 unknown
What steps can reproduce the bug?
When trying to run NextJS with Turbopack on bun, the direct import of bun-specific APIs does not work - but a namespaced import works, if the interfaces are exposed (kudos to @MichalBastrzyk). The Turbopack-Team already knows about this: vercel/next.js#75220
Namespaced version:
While this should be in general solved in turbopack (AFAIK), it would be nice to have a proper workaround for bun.
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: