Support custom `nyc.config.js` file in ESM projects

オープン
#668 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
nodejs, typescript

調査の方向性

エラーの61行目で参照されているtask-utils.jsのreadNycOptionsから始め、task.jsのgetNycOptionを通じた使用箇所を追跡します。リンクされたESMプロジェクトで失敗を再現し、その後、カスタムのnyc.config.jsが正常に読み込まれることと、既存の設定動作が維持されることを確認します。

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

説明

type: feature

Based off @cypress-io/cypress#26729

ESM projects cannot currently use a custom nyc.config.js file because this project uses require(..) to import that file - require does not support ESM modules.

Screenshot 2023-06-21 at 3 21 52 PM

This may be as simple as swapping out require(..) for an await import(..), but there may be dragons

Logs and screenshots

Error: Failed to load nyc.config.js: require() of ES Module /Users/mikep/Development/Scaffolds/firewatch/26729/nyc.config.js from /Users/mikep/Development/Scaffolds/firewatch/26729/node_modules/@cypress/code-coverage/task-utils.js not supported.
Instead change the require of nyc.config.js in /Users/mikep/Development/Scaffolds/firewatch/26729/node_modules/@cypress/code-coverage/task-utils.js to a dynamic import() which is available in all CommonJS modules.
    at readNycOptions (/Users/mikep/Development/Scaffolds/firewatch/26729/node_modules/@cypress/code-coverage/task-utils.js:61:13)
    at getNycOption (/Users/mikep/Development/Scaffolds/firewatch/26729/node_modules/@cypress/code-coverage/task.js:36:28)
    at Object. (/Users/mikep/Development/Scaffolds/firewatch/26729/node_modules/@cypress/code-coverage/task.js:58:3)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at ModuleWrap. (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at async loadFile (/Users/mikep/Library/Caches/Cypress/12.15.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:106:14)
    at async EventEmitter. (/Users/mikep/Library/Caches/Cypress/12.15.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:116:32)

Link to the repo

https://github.com/mike-plummer/code-coverage-668

主要言語
TypeScript
スター
440
フォーク
114
平均マージ
42分
マージ済み PR(30日)
19

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

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

cypress-io/code-coverage のほかの issue

cypress-io/code-coverage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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