Astro combined with vanilla-extract fails loading cssesc
when rendering a content collection item
#11395
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
Astro Info
I copy pasted as is, but my package manager is not
bun
, it’snpm
. I usebunx
instead ofnpx
which is slightly faster, but that’s all.If this issue only occurs in one browser, which browser is a problem?
It is an issue occurring on server side in the DEV server, so not linked to any browser.
Describe the Bug
The issue occurs only when the Vite plugin for vanilla-extract is added to Astro’s configuration and since Astro 4.2.5:
When executing
render()
on a content collection item (I tried only in the context of loading an Astro page which fetches content and callsrender
), the following error occurs (file names and line numbers may vary):cssesc.js
is not properly evaluated since it is using CommonJS and it is not translated.Example of such code trigering the issue:
It occurs only once per item. Therefore, reloading the page, going elsewhere and coming back to it, or going to another page rendering the same item will not fail anymore for that item, until the DEV server is restarted.
It does not fail at build time.
What's the expected result?
Well, the issue not to occur.
To be honest, since it’s in combination with vanilla-extract, I hesitated between their project and Astro’s to file an issue. And as of now, I’m still not sure who would be the culprit. Yet, it started to happen only once Astro started using
cssesc
, like vanilla-extract already did. It’s also related to how dependencies are loaded, and the issue does not happen at build time, leading to think that Astro’s discrepancies between dev vs build is at fault, and dev configuration would not be appropriate for some dependencies.Link to Minimal Reproducible Example
https://stackblitz.com/edit/stackblitz-starters-1kbjbz
The text was updated successfully, but these errors were encountered: