Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] ERR_REQUIRE_ESM with many libraries (react-use, emotion at least) #7268

Closed
6 tasks done
ddolcimascolo opened this issue Jan 16, 2025 · 1 comment · Fixed by #7271
Closed
6 tasks done

[v3] ERR_REQUIRE_ESM with many libraries (react-use, emotion at least) #7268

ddolcimascolo opened this issue Jan 16, 2025 · 1 comment · Fixed by #7271

Comments

@ddolcimascolo
Copy link

ddolcimascolo commented Jan 16, 2025

Describe the bug

Hello,

Tests that were passing with vitest@2 are now failing when they use a library such as react-use or emotion (a dependency of MUI). In our test suite, it's like 90% of tests :/ The error is

Error: require() of ES Module /data/dev/vitest-v3-require-esm/node_modules/tslib/tslib.es6.mjs not supported.
Instead change the require of /data/dev/vitest-v3-require-esm/node_modules/tslib/tslib.es6.mjs to a dynamic import() which is available in all CommonJS modules.
 ❯ Object.<anonymous> node_modules/react-use/lib/factory/createReducer.js:3:15

I created a repo with an easy reproduction, really nothing weird except a component using react-use : https://github.com/ddolcimascolo/vitest-v3-require-esm

A few details on the environment

  • Node 22
  • Vite latest
  • Vitest latest
  • HappyDOM as the test environment

Anything I can do to help, just ask.

Thanks !

David

Reproduction

https://github.com/ddolcimascolo/vitest-v3-require-esm

System Info

System:
    OS: Linux 6.8 Linux Mint 22 (Wilma)
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 2.83 GB / 15.35 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.11.0/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
  Browsers:
    Chrome: 132.0.6834.83
  npmPackages:
    @vitejs/plugin-react: 4.3.4 => 4.3.4 
    vite: 6.0.7 => 6.0.7 
    vitest: 3.0.0 => 3.0.0

Used Package Manager

npm

Validations

@ddolcimascolo
Copy link
Author

Sorry I just noticed #7266 which is probably the same issue. My repro may help, though.

Feel free to close anyway if that's a dupe !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant