uiwjs / uiwjs/react-codemirror
@uiw/codemirror-theme-* crashes vitest workers when --coverage is enabled
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pnpm-workspace.yaml and inspect the @uiw/codemirror-theme-* packages involved in the failing coverage run. Reproduce the issue with the repository's Vitest command and --coverage, then add the required packageExtensions entries for affected themes. Done means coverage completes without package-resolution errors and unrelated test files no longer fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100