stackblitz / tutorialkit

TutorialKit by StackBlitz - Create interactive tutorials powered by the WebContainer API
https://tutorialkit.dev
MIT License
507 stars 49 forks source link

chore(dev-deps): update `eslint`, `prettier`, `vitest` #333

Closed AriPerkkio closed 2 months ago

AriPerkkio commented 2 months ago
stackblitz[bot] commented 2 months ago

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Nemikolh commented 2 months ago

Nice! You also need to update the build.js script:

https://github.com/stackblitz/tutorialkit/blob/afbc81f241ea471eaf334514ad4ac2fa96bc3662/packages/astro/scripts/build.js#L47-L49

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?

AriPerkkio commented 2 months ago

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

Nemikolh commented 2 months ago

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:

Nemikolh commented 2 months ago

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?

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.