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

未关闭
#668 4 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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 分钟
30 天内合并 PR
19

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cypress-io/code-coverage 的其他 Issue

查看 cypress-io/code-coverage 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。