-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed as not planned
Closed as not planned
Copy link
Description
Describe the bug
We have a package that has a browser ESM & Node CJS & ESM builds. So exports looks something like this:
"exports": {
"types": "./dist/node.d.ts",
"browser": "./dist/browser.mjs",
"import": "./dist/node.mjs",
"require": "./dist/node.js"
},Vitest selects the Node ESM build even with environment: "jsdom". Annoyingly, this can be a good thing for some packages, and bad for others in tests.
See https://jestjs.io/docs/29.0/configuration#testenvironmentoptions-object for the config and special comment syntax for this issue supported by Jest.
This might be difficult to support without loader hooks though Node does have a --conditions flag.
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-4jwegg?file=test/basic.test.ts
System Info
System:
OS: macOS 12.6.2
CPU: (10) arm64 Apple M1 Pro
Memory: 123.48 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.0/bin/yarn
npm: 9.2.0 - ~/.nvm/versions/node/v16.19.0/bin/npm
Browsers:
Chrome: 108.0.5359.124
Safari: 16.2Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
No labels