Files
sweet/packages/plugin-vite/demo
Marvin Hagemeister a084a2c536 fix: unable to load CommonJS in vite plugin (#3204)
Vite has an internal check that limits CommonJS detection to only bare
specifier. This doesn't work well together with us resolving npm modules
to absolute file paths.


https://github.com/vitejs/vite/blob/main/packages/vite/src/node/ssr/fetchModule.ts#L46

I've tried re-using our own instance of `@rollup/plugin-commonjs` or
`esbuild` but couldn't get these to work in that setup. The easiest way
seems to be to just write our own CJS -> ESM translation layer.

With a little luck since the Deno ecosystem is heavy into ESM we might
get away with this. In either way this removes one of the two blockers
to using the vite plugin.
2025-08-08 00:04:16 +02:00
..