Skip to content

Vitest doesn't honor resolve conditions for nested modules in workspace. #5301

@DylanPiercey

Description

@DylanPiercey

Describe the bug

resolve.conditions config for workspace is ignored when resolving nested node_module.

When you import a module, which then imports another module that relies on export conditions vitest is not honoring those conditions if they are defined in the workspace config.

If you define the resolve conditions in the main vitest.config.ts it will resolve the nested module, however I am trying to have server & client tests in a workspace which need different conditions (the browser condition is different between them).

Note this previously worked fine in 1.2.2. It was broken in 1.3.0.

Reproduction

Clone https://github.com/DylanPiercey/vitest-resolve-condition-nested-issue

System Info

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 7.14 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/Library/Caches/fnm_multishells/47552_1708985680346/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.5 - ~/Library/Caches/fnm_multishells/47552_1708985680346/bin/npm
    pnpm: 8.15.1 - ~/pnpm/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
  Browsers:
    Chrome: 122.0.6261.69
    Edge: 122.0.2365.52
    Safari: 17.3.1
  npmPackages:
    @vitest/ui: latest => 1.3.1 
    vite: latest => 5.1.4 
    vitest: latest => 1.3.1

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions