Closed AriPerkkio closed 2 months ago
Run & review this pull request in StackBlitz Codeflow.
Nice! You also need to update the build.js
script:
This should be:
define: {
'process.env.TUTORIALKIT_DEV': JSON.stringify(process.env.TUTORIALKIT_DEV ?? null),
'process.env.VITE_INSPECT': JSON.stringify(process.env.VITE_INSPECT ?? null),
},
Also wondering if we should call it TUTORIALKIT_VITE_INSPECT
. Thoughts?
Nice! You also need to update the
build.js
script:
Interesting way of using Vite's define
- it overrides process.env.<var>
from environment variables. I guess this is so that you cannot use these environment variables after build?
Another interesting note: this is what dead-code-elimination does to this line. I guess there's some edge case why it has to leave await
there too:
- process.env.TUTORIALKIT_DEV ? (await import('vite-plugin-inspect')).default() : null,
+ null ? (await null).default() : null
https://unpkg.com/browse/@tutorialkit/astro@0.2.3/dist/index.js
Oh that's an odd one!
I've been trying to get esbuild to generate the same thing in their playground but failed. :open_mouth:
See this esbuild playground link.
It always eliminate the await
, even with minify: false
which is what we do for Astro. :thinking:
Interesting way of using Vite's
define
- it overridesprocess.env.<var>
from environment variables. I guess this is so that you cannot use these environment variables after build?
Btw, this is not using vite
, we use esbuild
directly for our Astro integration. And yes, the idea is that those environment variable cannot be used after a build.
We do this because vite-inspect-plugin
is a dev dependency of our Astro integration. So the the dynamic import would (always?) fail for our end users if they had those env vars defined by accident.
@blitz/eslint-plugin
eslint-plugin-astro
vitest
vite-plugin-inspect