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

Error No known conditions for "." specifier with vitest 3 #7277

Closed
6 tasks done
silverwind opened this issue Jan 17, 2025 · 4 comments
Closed
6 tasks done

Error No known conditions for "." specifier with vitest 3 #7277

silverwind opened this issue Jan 17, 2025 · 4 comments

Comments

@silverwind
Copy link
Contributor

silverwind commented Jan 17, 2025

Describe the bug

Since vitest 3, I'm running into a new resolve error relateded to the @neodrag/react npm module. The exact same code worked with vitest 2.

Vite is able to resolve and build this module fine (npx vite build works), it fails only with vitest. Let me know if you suspect a bug in the module, its source is here.

 FAIL  index.test.js [ index.test.js ]
Error: Failed to resolve entry for package "@neodrag/react". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "@neodrag/react" package
  Plugin: vite:import-analysis
  File: /Users/silverwind/git/vitest-resolve-bug/index.test.js:1:31
  1  |  import { useDraggable } from "@neodrag/react";

Reproduction

https://github.com/silverwind/vitest-resolve-bug

git clone https://github.com/silverwind/vitest-resolve-bug
cd vitest-resolve-bug
npm install
npx vitest

System Info

System:
    OS: macOS 15.2
    CPU: (16) arm64 Apple M3 Max
    Memory: 9.96 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.6.0 - /opt/homebrew/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 9.15.4 - ~/.npm-global/bin/pnpm
    bun: 1.1.43 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 132.0.6834.84
    Firefox Nightly: 129.0a1
    Safari: 18.2
  npmPackages:
    vitest: 3.0.1 => 3.0.1

Used Package Manager

npm

Validations

@silverwind silverwind changed the title Error Failed to resolve entry for package since vitest 3 Error No known conditions for "." specifier since vitest 3 Jan 17, 2025
@silverwind
Copy link
Contributor Author

silverwind commented Jan 17, 2025

@silverwind silverwind changed the title Error No known conditions for "." specifier since vitest 3 Error No known conditions for "." specifier with vitest 3.0.1 Jan 17, 2025
@silverwind silverwind changed the title Error No known conditions for "." specifier with vitest 3.0.1 Error No known conditions for "." specifier with vitest 3 Jan 17, 2025
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 18, 2025

This is likely an issue with development|production like mentioned in #7070 (comment). Let me close this as a duplicate.

Side note: technically Vite's resoltuion should fallback to "default": "./dist/min/index.js" https://publint.dev/@neodrag/react@2.3.0 when Vitest didn't set any of development or production, but it looks like Vite has a bug due to upstream lukeed/resolve.exports#35.

@silverwind
Copy link
Contributor Author

It's odd because the development export of that module seems to contain the same code as the production, but minified. I'd expect these to work the same.

@silverwind
Copy link
Contributor Author

Can confirm that #7301 has resolved this.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2025
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

2 participants