Skip to content

Module aliases fail to resolve in workspace setup with browser config #4744

@fubhy

Description

@fubhy

Describe the bug

I'm trying to configure a monorepo workspace project from the root with all config in vitest.workspace.ts. My intent is to run the entire test suite in different environments to verify cross-platform compatibility. I want to configure this in the workspace config directly for more fine grained control instead of using cli options.

The bug is that any browser configuration (no matter which provider is used) fails to resolve module aliases if they are configured from the workspace root. It works if they are configured e.g. via a package specific vitest.config.ts file but not via the workspace root config.

The provided reproduction showcases that in the simplest way possible.

Reproduction

https://github.com/fubhy/vitest-workspace-repro

System Info

System:
    OS: macOS 14.0
    CPU: (12) arm64 Apple M2 Max
    Memory: 117.16 MB / 32.00 GB
    Shell: 3.6.1 - /nix/store/brlkinambh1hg2baqy43fyi7x66nqy8q-fish-3.6.1/bin/fish
  Binaries:
    Node: 20.9.0 - /etc/profiles/per-user/fubhy/bin/node
    npm: 10.1.0 - /etc/profiles/per-user/fubhy/bin/npm
    pnpm: 8.10.2 - /etc/profiles/per-user/fubhy/bin/pnpm
    bun: 1.0.11 - /etc/profiles/per-user/fubhy/bin/bun
  Browsers:
    Chrome: 120.0.6099.109
    Safari: 17.0
  npmPackages:
    @vitest/browser: ^1.0.4 => 1.0.4
    vite: ^5.0.4 => 5.0.8
    vitest: 1.0.4 => 1.0.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)pr welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions