Skip to content

Forced noExternal causes Vitest to fail with Astro components #9324

@matthewp

Description

@matthewp

Describe the bug

This line that forces noExternal breaks testing Astro components because there are some CommonJS dependencies that can't be run through Vite's module loader.

environment.resolve.noExternal = true

Reproduction

https://github.com/HiDeoo/astro-6-vitest-repro

System Info

System:
    OS: macOS 15.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 769.50 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.21.1 - /Users/matthew/.volta/tools/image/node/22.21.1/bin/node
    Yarn: 1.22.19 - /Users/matthew/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 10.9.4 - /Users/matthew/.volta/tools/image/node/22.21.1/bin/npm
    pnpm: 9.15.9 - /Users/matthew/Library/pnpm/pnpm
    bun: 1.2.20 - /Users/matthew/.bun/bin/bun
    Deno: 2.6.3 - /opt/homebrew/bin/deno
  Browsers:
    Brave Browser: 140.1.82.166
    Chrome: 143.0.7499.147
    Chrome Canary: 145.0.7592.0
    Firefox: 137.0.2
    Safari: 18.6
  npmPackages:
    vitest: ^4.0.16 => 4.0.16

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions