bun icon indicating copy to clipboard operation
bun copied to clipboard

Vite Rollup fails on "bun:sqlite" import even when it is marked as external

Open joshdchang opened this issue 1 year ago • 8 comments

What version of Bun is running?

1.0.7+b0393fba6200d8573f3433fb0af258a0e33ac157

What platform is your computer?

Darwin 23.0.0 arm64 arm

What steps can reproduce the bug?

When importing bun:sqlite in a Vite/Rollup project, it causes an error on build.

import { Database } from "bun:sqlite";

I marked bun:sqlite as an external dependency (external: ["bun:sqlite"] in Rollup config), so it should be ignored but it isn't.

What is the expected behavior?

I expected the build to compile while allowing bun:sqlite to be external. The Vite dev server works as expected, this is just on build.

What do you see instead?

I'm getting the following error: Error [PLUGIN_ERROR]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'bun:'

Additional information

I am submitting this as an issue to Bun because I think it may be useful for cases like this to have a way to reference the bun:sqlite module without using the :, such as having bun/sqlite as an alias or just including it as part of the Bun object.

joshdchang avatar Oct 26 '23 23:10 joshdchang