Mark Bun built-ins as external #3398
Open
+75
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Users of various Vite-based frameworks have been hitting module resolution errors when trying Bun's built-in modules like
bun:sqlite
. These frameworks generally rely on esbuild's default behavior of marking Node.js built-ins as external & side-effect-free. This PR does the same for Bun's built-ins:bun:*
modules andbun
itself.Happy to update this to explicitly list each Bun builtin:
bun:test
,bun:ffi
,bun:sqlite
, etc. But we'll likely update this list several times in the future and I was worried about maintainence burden for esbuild. So currently this PR just checks for thebun:
prefix. Unlike Node.js, Bun requires usage of thebun:
prefix for its built-in modules.Some of the issues this fixes
bun:sqlite
package. withastro/astro#8476bun:*
packages vitejs/vite#14351