You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although npm run dev/build works perfectly, npm run test (vitest) throws out an error:
SyntaxError: Named export 'parse' not found. The requested module 'css-what' is a CommonJS module, which may not support all module.exports as named exports.
After some investigation, the offending code (deep in my dependency chain) turns out to be:
import{parse}from"css-what"
It seems that somehow vitest incorrectly considers a perfect es module (css-what) as cjs, thus refusing to import it.
However, commenting out vite-plugin-svelte in vite.config can make the error go away in vitest (and obviously breaks my code):
npm run dev to see that vite and svelte work fine:
The root page should display some json, indicating that the miminal code works.
npm run test to reproduce the error msg:
SyntaxError: Named export 'parse' not found. The requested module 'css-what' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'css-what';
const { parse } = pkg;
commenting out vite-plugin-svelte in vite.config, then npm run tset won't raise any error:
Describe the bug
Although
npm run dev/build
works perfectly,npm run test
(vitest) throws out an error:After some investigation, the offending code (deep in my dependency chain) turns out to be:
It seems that somehow vitest incorrectly considers a perfect es module (
css-what
) as cjs, thus refusing to import it.However, commenting out
vite-plugin-svelte
in vite.config can make the error go away in vitest (and obviously breaks my code):Dependency chain:
My code:
@tiptap/html
:zeed-dom
:Reproduction
https://stackblitz.com/github/andy1li/vitest-bug-report
npm run dev
to see that vite and svelte work fine:npm run test
to reproduce the error msg:vite-plugin-svelte
in vite.config, thennpm run tset
won't raise any error:Logs
vite:resolve 2.43ms css-what -> /Users/andy/Desktop/vitest-bug-report/node_modules/.pnpm/css-what@6.1.0/node_modules/css-what/lib/es/index.js +55ms ❯ src/tiptap.test.ts (0)
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: