Skip to content

Conversation

@ianzone
Copy link
Contributor

@ianzone ianzone commented Nov 21, 2025

这个 PR 做了什么? (简要描述所做更改)

  1. 新的v8报告器提供了与istanbul相同的准确度及更快的速度,故改用v8。 v8报告器与 node18不兼容,暂时保持Istanbul
  2. 更新vite和vitest版本

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 杂务
    • 升级测试框架 Vitest(v3 → v4),并在根与子包中新增/调整 Vite 相关依赖
    • 替换 devDependency 覆盖工具为 @vitest/coverage-v8
    • 在多个测试配置中移除显式的 coverage provider 配置,使用默认提供者
    • 更新测试脚本参数(--updateSnapshot → --update)
    • 移除测试 mock 中 image 组件的 lang 属性

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 21, 2025

演练

该拉取请求更新了多个包中的Vitest和Vite依赖版本,调整了Vitest配置以支持新版本,更新了测试脚本命令,并从测试模拟文件中移除了一个不再使用的组件属性。

变更

内聚/文件 变更摘要
依赖更新
package.jsonpackages/taro/package.json
升级 @vitest/coverage-istanbul 从 ^3.2.4 到 ^4.0.13;升级 vitest 从 ^3.2.4 到 ^4.0.13;新增 vite ^7.2.4(根目录)和 vite ^4.2.0(packages/taro)
Vitest配置调整
packages/taro-framework-vue3/vitest.config.tspackages/babel-plugin-transform-taroapi/vitest.config.mts
修复whitespace格式;移除显式的 provider: 'istanbul' 配置,由新Vitest版本默认提供
测试工具链更新
packages/babel-plugin-transform-taroapi/package.json
更新 updateSnapshot 脚本命令从 vitest run --updateSnapshot 改为 vitest run --update
测试模拟数据清理
packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json
从image组件schema中移除 lang: string 属性

预计代码审查工作量

🎯 2 (Simple) | ⏱️ ~12 分钟

  • 关注点:验证Vitest ^4.0.13与现有测试套件的兼容性,确保脚本命令别名 --update 在新版本中正确工作
  • 关注点:确认从image组件移除 lang 属性不会影响依赖该属性的测试或业务逻辑

可能相关的PR

建议的审查者

  • luckyadam
  • yoyo837
  • tutuxxx

🐰 依赖升级小步跑
Vitest新版本来到
配置优化心欢喜
测试命令焕新彩
兔子欢呼又跳跃 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning PR标题为 "test: vitest更新",但PR的实际目标是将coverage工具从istanbul替换为v8,并更新Vite和Vitest版本,标题未能准确反映主要变更。 建议修改PR标题更准确地反映主要变更,例如 "test: replace istanbul with v8 coverage provider and upgrade vitest" 或类似表述。
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81fc3c6 and d94ae0b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • packages/taro/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: ianzone
Repo: NervJS/taro PR: 18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
📚 Learning: 2025-08-08T02:32:58.265Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。

Applied to files:

  • packages/taro/package.json
📚 Learning: 2025-09-05T18:40:45.775Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/taro-platform-harmony-hybrid/package.json:43-45
Timestamp: 2025-09-05T18:40:45.775Z
Learning: 在 tarojs/plugin-platform-harmony-hybrid 包中,tarojs/components-library-react、tarojs/components-library-solid 和 tarojs/components-library-vue3 必须作为直接依赖(dependencies)而不能作为 peer 依赖,因为插件源码中有对这些包的直接引用,包括 componentAdapter* getter 方法和 webpack 别名配置。

Applied to files:

  • packages/taro/package.json
🔇 Additional comments (1)
packages/taro/package.json (1)

39-40: packages/taro 应在 peerDependencies 中声明 vite,并解决版本不一致。

根据验证,packages/taro 的类型定义中大量使用了 vite 类型(如 ViteServerOptions),且该包被下游应用依赖。vite 仅作为 devDependency 是不足的,应同时添加到 peerDependencies 中,以确保下游应用知道需要提供此依赖。

此外,packages/taro 中的 vite ^4.2.0(2023 年版本)与根目录 package.json 中的 ^7.2.4 存在重大版本差异,可能导致类型不匹配或编译问题。建议:

  1. 将 vite 添加到 packages/taro 的 peerDependencies(例如 "vite": "^4.2.0"
  2. 协调 vite 版本,确保与根目录或其他子包保持一致,或明确说明为何需要特定版本

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62a2cb9 and 1619707.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (2 hunks)
  • packages/taro-framework-vue3/vitest.config.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/taro-framework-vue3/vitest.config.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-08T02:32:58.265Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。

Applied to files:

  • package.json
📚 Learning: 2025-11-21T07:15:22.626Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18646
File: packages/taro/package.json:40-40
Timestamp: 2025-11-21T07:15:22.626Z
Learning: 在 tarojs/taro 包中添加 vite 作为 devDependency 是为了让 tarojs/vite-runner 能够依赖正确的 vite 类型版本,确保 monorepo 中的类型兼容性。

Applied to files:

  • package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (1)
package.json (1)

167-168: Vite 版本跨度过大,导致 monorepo 中类型和 API 不兼容

根目录 package.json 第 167 行的 "vite": "^7.2.4" 与 monorepo 中所有其他 packages 的 "vite": "^4.2.0" 存在主版本差异。Vite 4 到 7 存在重大破坏性变更,这将导致:

  1. 类型定义冲突(packages/taro-vite-runner 特别需要与根 vite 版本一致)
  2. API 不兼容
  3. 插件和配置不适配

需要同步更新以下文件中的 Vite 版本:

  • packages/taro/package.json
  • packages/taro-framework-react/package.json
  • packages/taro-framework-solid/package.json
  • packages/taro-framework-vue3/package.json
  • packages/taro-platform-harmony-cpp/package.json
  • packages/taro-vite-runner/package.json
⛔ Skipped due to learnings
Learnt from: ianzone
Repo: NervJS/taro PR: 18646
File: packages/taro/package.json:40-40
Timestamp: 2025-11-21T07:15:22.634Z
Learning: 在 tarojs/taro 包中添加 vite 作为 devDependency 是为了让 tarojs/vite-runner 能够依赖正确的 vite 类型版本,确保 monorepo 中的类型兼容性。
Learnt from: ianzone
Repo: NervJS/taro PR: 18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/taro-platform-harmony-hybrid/package.json:43-45
Timestamp: 2025-09-05T18:40:45.775Z
Learning: 在 tarojs/plugin-platform-harmony-hybrid 包中,tarojs/components-library-react、tarojs/components-library-solid 和 tarojs/components-library-vue3 必须作为直接依赖(dependencies)而不能作为 peer 依赖,因为插件源码中有对这些包的直接引用,包括 componentAdapter* getter 方法和 webpack 别名配置。

"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vitest/coverage-istanbul": "^3.2.4",
"@vitest/coverage-istanbul": "^4.0.13",
Copy link

@coderabbitai coderabbitai bot Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

PR 目标与实现不一致:应使用 v8 而非 istanbul

PR 目标声称"用新的 v8 reporter 替换现有的 istanbul",但该行仍保留 @vitest/coverage-istanbul。Vitest 4 默认使用 v8 作为覆盖率提供者,建议将依赖从 @vitest/coverage-istanbul 改为 @vitest/coverage-v8 以达成 PR 目标。V8 已采用基于 AST 的覆盖率重新映射,提供与 Istanbul 相同的准确性,同时保持 V8 的速度优势。

请验证:

  1. 此变更是否意在完全迁移到 v8(应替换 istanbul 包)或仅更新 istanbul 包版本
  2. 项目中的 vitest.config 文件是否已更新为 provider: 'v8'(如已在其他 PR 文件中修改)
  3. 若确实迁移到 v8,请应用以下修改:
-    "@vitest/coverage-istanbul": "^4.0.13",
+    "@vitest/coverage-v8": "^4.0.13",





---

🏁 Script executed:

```shell
#!/bin/bash
# 查找 vitest.config 文件
find . -type f -name "vitest.config.*" 2>/dev/null | head -20

Length of output: 511


🏁 Script executed:

#!/bin/bash
# 检查 packages/taro 目录中的 vite 版本
if [ -f "packages/taro/package.json" ]; then
  cat "packages/taro/package.json" | grep -A2 -B2 '"vite"'
fi

Length of output: 111


🏁 Script executed:

#!/bin/bash
# 搜索 coverage provider 相关配置
rg -i "provider.*coverage|coverage.*provider" --type=js --type=ts -C3 2>/dev/null | head -30

Length of output: 0


🏁 Script executed:

#!/bin/bash
# 查看根目录 package.json 中的 devDependencies 覆盖率相关包
grep -A50 '"devDependencies"' package.json | grep -E "coverage|vitest"

Length of output: 43


🌐 Web query:

Vitest 4 coverage provider v8 vs istanbul differences

💡 Result:

Short summary — key differences between Vitest's v8 and istanbul coverage providers:

  • How they collect coverage

    • v8: native V8 engine profiler (node:inspector / CDP) at runtime — no source instrumentation. [1][2]
    • istanbul: instrumentation-based (instrument code before/while running) using Istanbul tooling. [1]
  • Performance and resource use

    • v8: generally faster and lower memory (no instrumentation step). Can be slower in some scenarios (many modules). [1]
    • istanbul: usually slower and higher memory due to instrumentation, but can be faster for some workloads. [1]
  • Accuracy / remapping

    • v8: Vitest uses AST-based remapping (since v3.2.0 / improved in v4) to produce coverage equivalent to Istanbul for most cases. [3][1]
    • istanbul: produces coverage from instrumented sources (classic Istanbul reports). [1]
  • Environment support / limitations

    • v8: requires a V8-based runtime (Node, Chrome, Deno). Not supported in non‑V8 runtimes (e.g., Firefox, Bun in some cases) or environments that don’t expose V8 profiler. V8 also cannot limit coverage to specific modules (engine limitation). [1]
    • istanbul: works broadly (non‑V8 runtimes too) because it relies on instrumentation rather than the engine API. [1]
  • Configuration / UX

    • v8: default provider in Vitest; no pre‑transpile/instrument step; Vitest will prompt to install @vitest/coverage-v8. [1][4]
    • istanbul: opt‑in via provider setting; requires @vitest/coverage-istanbul if chosen. [1][4]
  • Small behavioral diffs / migration notes (Vitest 4)

    • V8 remapping logic was improved in Vitest 4 (AST-based) so v8 reports match Istanbul more closely; some ignore/hint handling changed and certain options (e.g., coverage.ignoreEmptyLines) were removed/updated. Expect differences when upgrading. [3]

Sources: Vitest docs — Coverage guide and Config (v8 vs istanbul, provider defaults, limitations) and the Vitest migration notes about V8 remapping. [1][2][3]

References
[1] Vitest — Coverage guide.
[2] Vitest — Config › coverage.provider.
[3] Vitest — Migration notes (V8 coverage changes).


🌐 Web query:

@vitest/coverage-v8 package version 4.0.13

💡 Result:

Yes — @vitest/coverage-v8 v4.0.13 is available. Install with:

npm:
npm install -D @vitest/[email protected]

yarn:
yarn add -D @vitest/[email protected]

Changelog highlights for 4.0.13 (bug fixes and performance tweaks) are listed in the release notes. [1][2]

Sources:
[1] Snyk package page showing latest version 4.0.13.
[2] Release notes / changelog entry for v4.0.13.



---

🏁 Script executed:

```shell
#!/bin/bash
# 查看根目录 vitest.config.ts
cat ./vitest.config.ts

Length of output: 139


🏁 Script executed:

#!/bin/bash
# 查看 packages/taro/package.json 中 vitest 版本
grep -A1 -B1 '"vitest"' packages/taro/package.json

Length of output: 0


🏁 Script executed:

#!/bin/bash
# 在 vitest.config 文件中搜索 coverage 相关配置(更宽泛的搜索)
grep -r "coverage\|provider" . --include="vitest.config.*" 2>/dev/null | grep -v node_modules

Length of output: 1431


🏁 Script executed:

#!/bin/bash
# 检查 PR 中是否添加了 @vitest/coverage-v8
grep -E "coverage-v8|coverage-istanbul" package.json

Length of output: 43


PR 目标与实现严重不符:覆盖率提供者迁移未完成

PR 声称"用新的 v8 reporter 替换现有的 istanbul",但实际代码中:

  1. package.json:仅更新 @vitest/coverage-istanbul 到 ^4.0.13,未添加 @vitest/coverage-v8
  2. 所有 vitest.config 文件(packages/*/vitest.config.ts):10 个包的 coverage provider 仍配置为 'istanbul',未改为 'v8'

若要完成迁移到 v8,需要:

# package.json
-    "@vitest/coverage-istanbul": "^4.0.13",
+    "@vitest/coverage-v8": "^4.0.13",
# packages/*/vitest.config.ts(所有 10 个包)
     coverage: {
-      provider: 'istanbul',
+      provider: 'v8',

次要问题:Vite 版本不一致——根目录 ^7.2.4 vs packages/taro ^4.2.0(跨主版本),建议统一版本并验证兼容性。

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In package.json around line 112, the PR only bumped @vitest/coverage-istanbul
but did not add the new v8 reporter and did not update vitest configs; add the
dependency @vitest/coverage-v8 at a compatible version, remove or deprecate
@vitest/coverage-istanbul if no longer used, then update all
packages/*/vitest.config.ts files to set coverage.provider = 'v8' (replace
'istanbul') and run tests to verify reports; additionally reconcile Vite
versions by aligning root package.json and packages/taro to the same major
version (e.g., both ^7.x or both ^4.x) and test for compatibility before
finalizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v8与node18不兼容,已更改PR目标

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@ianzone ianzone changed the title test: v8 test: vitest更新 Nov 23, 2025
@ianzone ianzone closed this Nov 23, 2025
@ianzone ianzone deleted the v8 branch November 23, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant