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
I have created an ESM package (parent) that imports a CJS package (child), which in turn imports an ESM-only package (es-cookie).
When running vitest on the parent package I get the following error:
│ Error: require() of ES Module /home/runner/vitest-cjs/node_modules/.pnpm/es-cookie@1.4.0/node_modules/es-cookie/src/es-cookie.js from /home/runner/vite…
│ Instead change the require of es-cookie.js in /home/runner/vitest-cjs/packages/child/dist/cjs/index.js to a dynamic import() which is available in all …
│ ❯ async /home/runner/vitest-cjs/packages/parent/src/index.ts:1:31
│ ❯ async /home/runner/vitest-cjs/packages/parent/src/index.test.ts:2:31
When the child package is ESM instead of CJS, tests run as expected, though. Yet, we do not have control over this child package, so we cannot convert it to ESM. I have tried inlining es-cookie, but the issue did not resolve. This issue is preventing us from moving from jest to vitest.
Reproduction
I have created an environment that reproduces the error here: https://replit.com/@betabandido/vitest-cjs (I just realized a StackBlitz environment was requested, but hopefully the Replit one is good too; if that's not the case, please let me know, and I'll move it to StackBlitz).
To build and test both packages, run:
pnpm -r build
pnpm -r test
The second command should fail with the error described above.
Describe the bug
I have created an ESM package (parent) that imports a CJS package (child), which in turn imports an ESM-only package (es-cookie).
When running vitest on the parent package I get the following error:
When the child package is ESM instead of CJS, tests run as expected, though. Yet, we do not have control over this child package, so we cannot convert it to ESM. I have tried inlining
es-cookie
, but the issue did not resolve. This issue is preventing us from moving from jest to vitest.Reproduction
I have created an environment that reproduces the error here: https://replit.com/@betabandido/vitest-cjs (I just realized a StackBlitz environment was requested, but hopefully the Replit one is good too; if that's not the case, please let me know, and I'll move it to StackBlitz).
To build and test both packages, run:
pnpm -r build pnpm -r test
The second command should fail with the error described above.
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: