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

Import of library is undefined in browser mode #4505

Closed
6 tasks done
apdrsn opened this issue Nov 15, 2023 · 1 comment
Closed
6 tasks done

Import of library is undefined in browser mode #4505

apdrsn opened this issue Nov 15, 2023 · 1 comment

Comments

@apdrsn
Copy link

apdrsn commented Nov 15, 2023

Describe the bug

Hi team! Thanks for the great work on Vitest! 🙏
When running a test with browser mode enabled (using Playwright), my third party library lcid is undefined, and test will fail.
If I try with browser mode disabled, lcid is available and test passes.
See github repo example for reproduction. (could not get browsers to work in stackblitz)

Reproduction

https://github.com/apdrsn/vitest-import-bug

Run:
yarn playwright install
yarn playwright install-deps
yarn test

System Info

System:
  OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
  CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  Memory: 4.60 GB / 15.30 GB
  Container: Yes
  Shell: 5.8 - /usr/bin/zsh
Binaries:
  Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
  Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.2/bin/yarn
  npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm
Browsers:
  Chrome: 116.0.5845.96
npmPackages:
  @vitejs/plugin-react-swc: ^3.4.1 => 3.4.1
  @vitest/browser: 0.34.6 => 0.34.6
  vite: ^4.5.0 => 4.5.0
  vitest: 0.34.6 => 0.34.6

Used Package Manager

yarn

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Dec 6, 2023

I think this was a duplicate of #4264 (lcid is cjs package) and the issue seems to be slowHijackESM: true which was the default before #4414.
You can either manually set it to slowHijackESM: false or upgrade Vitest v1 so that it's false by default.

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

No branches or pull requests

3 participants