-
-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Description
Problem
Tests pass without --coverage but fail when coverage is enabled, with errors like:
Error: Cannot find package '@lezer/highlight' imported from
.../node_modules/.pnpm/@uiw+codemirror-theme-github@.../node_modules/@uiw/codemirror-theme-github/...
Unrelated test files also fail because vitest runs multiple test files per worker — one package load failure crashes the whole worker.
Root Cause
@uiw/codemirror-theme-* packages import @lezer/highlight internally but don't declare it as a dependency in their package.json. This is a bug in those upstream
packages.
Why it only fails with --coverage:
- Without
--coverage: Vite bundles the theme packages through its own resolver, which searches broadly across the workspace and finds@lezer/highlightin
packages/app/node_modules. No error. - With
--coverage: vitest's v8 coverage provider loadsnode_modulespackages via Node's native ESM loader for instrumentation, bypassing Vite's resolver
entirely. Node follows pnpm's strict isolation rules — a package can only resolve its declared dependencies — so@lezer/highlightis not found.
Why npm/yarn users don't hit this: Both use a flat node_modules layout where any package can access anything installed. pnpm's virtual store enforces
declared-dependency isolation.
Workaround
Add packageExtensions entries in pnpm-workspace.yaml for each affected theme package, declaring @lezer/highlight as a dependency:
packageExtensions:
"@uiw/codemirror-theme-github@*":
dependencies:
"@lezer/highlight": "*"
"@uiw/codemirror-theme-vscode@*":
dependencies:
"@lezer/highlight": "*"
# ... other @uiw/codemirror-theme-* packages
pnpm then symlinks @lezer/highlight into each theme package's virtual store node_modules, making it available regardless of loader — Vite, Node, or the v8 coverage
provider. Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels