Open jcayzac opened 4 months ago
Original issue here: https://github.com/withastro/astro/issues/11395
I got this problem too, only appears when loading for the first time, and will be restored when reloading from #11395
I'm also running into this error. I'm currently experimenting with the https://vitejs.dev/config/dep-optimization-options#optimizedeps-include setting, monkey-patching vanilla-extract and/or trying to adjust the Astro config. No luck so far :/
Meanwhile, I just copied cssesc.js into overrides/cssesc/index.ts
, patched it, and added this to my package.json
:
"overrides": {
"cssesc": "./overrides/cssesc"
}
This fixes it for me. I don't expect I'll need to maintain this fork, seeing the original package is dead (5+ years with no update).
Thanks for that info! I also did that now, as a workaround it'll be fine for me. If anyone from Google finds this, here's what you'll need to do:
Copy https://github.com/mathiasbynens/cssesc/blob/cb894eb42f27c8d3cd793f16afe35b3ab38000a1/cssesc.js into a location in your project and call it index.cjs
. Also add a package.json
that can be as minimal as e.g. like this:
index.mjs
. At the bottom of the index.mjs
file, change the export to: export default cssesc
"pnpm": {
"overrides": {
"cssesc": "./overrides/cssesc"
}
}
@jcayzac How did you patch the file exactly? Actually, the patch I described above doesn't work during astro build
and I have to remove it. It works fine for astro dev
though.
@LekoArts I just replaced the commonjs export with an esm export.
Gotcha 👍 I've updated my previous message with the instructions now that work for me both in dev and build. I just changed it to provide a dual CJS/ESM package where the index.cjs
has the CJS export, index.mjs
the ESM one.
Describe the bug
cssesc.js is CommonJS and can't be imported as a module.
Reproduction
https://stackblitz.com/edit/stackblitz-starters-1kbjbz
System Info
Used Package Manager
npm
Logs
Validations