-
Notifications
You must be signed in to change notification settings - Fork 62
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
feat: experimental native bun support #156
Conversation
This sounds like a bug. Does it really not work in general with .mjs or is there something more specific going wrong? |
To make import.meta.env work, I think you could override the getter on the import.meta object and define an env property to return either Bun.env or process.env. Something like
|
Reproduction: https://github.com/unjs/jiti/blob/main/test/fixtures/typescript/index.ts
|
Thanks! I wasn't sure if extending |
@@ -49,6 +50,7 @@ const defaults: JITIOptions = { | |||
alias: _EnvAlias, | |||
nativeModules: _EnvNative || [], | |||
transformModules: _EnvTransform || [], | |||
experimentalBun: _ExpBun === undefined ? !!process.versions.bun : !!_ExpBun, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving Bun detection into https://github.com/unjs/std-env?
π Linked issue
resolves #154
β Type of change
π Description
When running in Bun runtime we can leverage Bun's native typescript and CJS handling.
Running current fixtures against Bun, it seems platform support is extremely good and we can directly depend on Bun's
require
implementation π―There might be more runtime differences but I think generally for the sake of performance, worth to make Jiti bypass all transforms.
Known issues:
import.meta.env
is not supported.mts
as.mjs
On known issues, jiti falls back to it's default behavior to increase compatibility
/cc @birkskyum @paperdave @Jarred-Sumner
TODO:
nuxt.config.ts
)JITI_EXPERIMENTAL_BUN: false
orexperimentalBun: false
)π Checklist