-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Thank you for this plugin! It is working really well for me, but I am running into one issue. Vite has some built in constants that live on import.meta.env that are not strings. import.meta.env.{DEV,PROD,SSR} are all booleans.
When setting process.env.DEV in node.js the value gets coerced to a string, which leads to a runtime discrepancy where in tests import.meta.env.DEV will be "true" | "false" instead of boolean.
I'm not 100% sure what the fix here is, but maybe there could be a configuration parameter to this plugin to set some properties somewhere other than process.env.
{
"experimental": {
"plugins": [
[
"swc-plugin-import-meta-env",
{
"globalThis.fakeProcessEnv": ["DEV", "PROD", "SSR"]
}
]
]
},which would transform
console.log(import.meta.env.FOO);
console.log(import.meta.env.PROD);into
console.log(process.env.FOO);
console.log(globalThis.fakeProcessEnv.PROD);wdyt?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers