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
I was playing with SSR on Astro (uses Vite) with Bun, and as soon as I try importing anything that uses the Bun API, like "bun:sqlite" it fails to resolve with the following error...
error Cannot find module 'bun:sqlite' imported from '/home/andri/git/event-puffin-astro/src/lib/db/index.ts'
Error: Cannot find module 'bun:sqlite' imported from '/home/andri/git/event-puffin-astro/src/lib/db/index.ts'
at nodeImport (file:///home/andri/git/event-puffin-astro/node_modules/vite/dist/node/chunks/dep-df561101.js:56010:25)
at ssrImport (file:///home/andri/git/event-puffin-astro/node_modules/vite/dist/node/chunks/dep-df561101.js:55912:30)
at eval (/home/andri/git/event-puffin-astro/src/lib/db/index.ts:3:50)
at instantiateModule (file:///home/andri/git/event-puffin-astro/node_modules/vite/dist/node/chunks/dep-df561101.js:55974:15)
I found someone with a similar problem on the Astro issue tracker.
I went digging, and found the following snippet in nodeResolver() in Vite. I'm not that familiar with Vite's code-base, but I'd assume adding id.startsWith('bun:') there would fix the problem.
async function nodeImport(
id: string,
importer: string,
resolveOptions: InternalResolveOptionsWithOverrideConditions,
) {
let url: string
/* WE NEED TO ADD BUN HERE */
if (id.startsWith('node:') || id.startsWith('data:') || isBuiltin(id)) {
url = id
} else {
// Internal Vite resolution stuff. Uses node-resolve Rollup plugin.
}
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
I was playing with SSR on Astro (uses Vite) with Bun, and as soon as I try importing anything that uses the Bun API, like "bun:sqlite" it fails to resolve with the following error...
I found someone with a similar problem on the Astro issue tracker.
I went digging, and found the following snippet in
nodeResolver()
in Vite. I'm not that familiar with Vite's code-base, but I'd assume addingid.startsWith('bun:')
there would fix the problem.Reproduction
Astro + Bun
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: