@uiw/codemirror-theme-* crashes vitest workers when --coverage is enabled

オープン 初心者向け
#765 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript

調査の方向性

pnpm-workspace.yaml から始め、失敗している coverage 実行に関係する @uiw/codemirror-theme-* packages を調査します。リポジトリの Vitest コマンドと --coverage を使って問題を再現し、その後、影響を受ける themes に必要な packageExtensions エントリを追加します。coverage が package-resolution errors なしで完了し、無関係な test files が失敗しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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/highlight in
    packages/app/node_modules. No error.
  • With --coverage: vitest's v8 coverage provider loads node_modules packages 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/highlight is 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.                                                                                                                                                             
主要言語
TypeScript
スター
2.3k
フォーク
161
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

uiwjs/react-codemirror のほかの issue

uiwjs/react-codemirror の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。