-
Notifications
You must be signed in to change notification settings - Fork 4.9k
test(babel-plugin-transform-solid-jsx): vitest #18607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Walkthrough将多个包的测试体系从 Jest 迁移到 Vitest:更新/添加根与包内 devDependencies(包括 Vitest、Vite、coverage 适配器与 PostCSS/Rollup 版本调整)、删除部分 Jest 配置、替换测试脚本为 Vitest、新增/修改多包的 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as 开发者
participant Repo as 仓库
participant CI as CI
participant Jest as Jest(旧流程)
participant Vitest as Vitest(新流程)
rect rgb(250,240,240)
Note over Dev,Jest: 迁移前(Jest)
Dev->>Repo: 运行 npm test / CI 触发
Repo->>Jest: 调用 jest(jest.config.js / package.json scripts)
Jest->>CI: 运行测试并收集 coverage(istanbul)
Jest-->>Repo: 返回测试结果与 coverage 报告
end
rect rgb(240,250,240)
Note over Dev,Vitest: 迁移后(Vitest)
Dev->>Repo: 运行 npm test / CI 触发
Repo->>Vitest: 调用 vitest(vitest.config.ts / package.json scripts)
Vitest->>CI: 运行测试并收集 coverage(v8 / 默认 provider)
Vitest-->>Repo: 返回测试结果与 coverage 报告
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 分钟
Possibly related PRs
Suggested reviewers
诗歌
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ 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). (1)
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. Comment |
There was a problem hiding this 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
package.json(1 hunks)packages/babel-plugin-transform-solid-jsx/jest.config.js(0 hunks)packages/babel-plugin-transform-solid-jsx/package.json(1 hunks)packages/babel-plugin-transform-solid-jsx/test/unique-transform.spec.js(1 hunks)packages/babel-plugin-transform-solid-jsx/vitest.config.ts(1 hunks)
💤 Files with no reviewable changes (1)
- packages/babel-plugin-transform-solid-jsx/jest.config.js
🧰 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 中依赖提升的标准做法。
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json:2356-2356
Timestamp: 2025-08-25T22:16:50.118Z
Learning: The file `packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json` is auto-generated by the post-build script `packages/taro-platform-h5/scripts/post-build.mjs`, which copies content from `taro-platform-h5/dist/definition.json`. This file should not be manually edited.
📚 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.jsonpackages/babel-plugin-transform-solid-jsx/package.jsonpackages/babel-plugin-transform-solid-jsx/vitest.config.ts
📚 Learning: 2025-08-25T22:16:50.118Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json:2356-2356
Timestamp: 2025-08-25T22:16:50.118Z
Learning: The file `packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json` is auto-generated by the post-build script `packages/taro-platform-h5/scripts/post-build.mjs`, which copies content from `taro-platform-h5/dist/definition.json`. This file should not be manually edited.
Applied to files:
packages/babel-plugin-transform-solid-jsx/package.jsonpackages/babel-plugin-transform-solid-jsx/vitest.config.tspackages/babel-plugin-transform-solid-jsx/test/unique-transform.spec.js
🧬 Code graph analysis (1)
packages/babel-plugin-transform-solid-jsx/test/unique-transform.spec.js (1)
packages/babel-plugin-transform-solid-jsx/rollup.config.mjs (1)
__filename(6-6)
⏰ 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 - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- 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 WASM / stable - wasm32-wasi
🔇 Additional comments (3)
packages/babel-plugin-transform-solid-jsx/test/unique-transform.spec.js (1)
1-7: ESM 迁移实现正确测试文件已正确从 CommonJS 迁移到 ESModule:
- 使用
import语法替代require- 通过
fileURLToPath(import.meta.url)正确实现了 ESM 环境下的__filename和__dirnamepolyfill- 导入路径使用了明确的
.js扩展名,符合 ESM 规范该实现模式与项目中其他文件(如
rollup.config.mjs)保持一致。packages/babel-plugin-transform-solid-jsx/package.json (1)
25-27: 测试脚本已正确迁移到 Vitest测试脚本从 Jest 迁移到 Vitest 的更改正确:
test:ci:从jest --ci -i改为vitest run --coveragetest:从jest --no-cache改为vitest runtest:coverage:从jest --coverage --no-cache改为vitest run --coverage符合项目的 monorepo 管理模式,Vitest 依赖在根目录管理。
packages/babel-plugin-transform-solid-jsx/vitest.config.ts (1)
1-13: 需要检查包的具体结构和文件内容,继续验证:需要检查具体包的结构,执行脚本获取更多信息:
Based on my research, I've identified an issue with the original review comment. Vitest documentation shows that to include uncovered files in the report, you should configure coverage.include with a pattern that will pick your source files, typically using patterns like 'src/**/*.{ts,tsx}'.
The original review comment suggests changing
include: ['index.js']toinclude: ['dist/index.js'], but this contradicts Vitest best practices. Istanbul coverage tracking is done by instrumenting user's source files, meaning adding additional Javascript in user's files, not in build output.However, I need to verify the actual package structure to determine the correct configuration. Let me check the package structure:
基于我的验证,原始审查评论存在不准确之处。Vitest 官方文档推荐配置 coverage.include 以选择源文件,例如
'src/**/*.{ts,tsx}'这样的模式。Istanbul 代码覆盖工具通过对用户源文件进行代码插装来追踪覆盖率,而非构建后的文件。原始审查评论建议"如果应该覆盖构建后的代码,可能需要改为
include: ['dist/index.js']"与 Vitest 最佳实践相悖。覆盖率配置应该指向源文件,让 Vitest 在测试运行时自动转译。不要按照原始审查评论的建议改为 dist/ 路径。
根据 Taro monorepo 的标准实践和已发现的文件位置(根目录和 src/ 目录都有 index.js),当前配置应该要么保持
include: ['index.js'](如果入口点在根目录),要么改为include: ['src/index.ts']或类似的源文件模式(如果源代码在 src/ 目录)。Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (9)
package.json(2 hunks)packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts(0 hunks)packages/babel-plugin-transform-solid-jsx/vitest.config.ts(1 hunks)packages/babel-plugin-transform-taroapi/vitest.config.ts(0 hunks)packages/babel-preset-taro/vitest.config.ts(0 hunks)packages/css-to-react-native/vitest.config.ts(0 hunks)packages/shared/vitest.config.ts(0 hunks)packages/taro-extend/vitest.config.ts(0 hunks)packages/taro-runtime/vitest.config.ts(0 hunks)
💤 Files with no reviewable changes (7)
- packages/babel-preset-taro/vitest.config.ts
- packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/vitest.config.ts
- packages/css-to-react-native/vitest.config.ts
- packages/taro-runtime/vitest.config.ts
- packages/taro-extend/vitest.config.ts
- packages/babel-plugin-transform-taroapi/vitest.config.ts
- packages/shared/vitest.config.ts
🧰 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 中依赖提升的标准做法。
Learnt from: ianzone
Repo: NervJS/taro PR: 17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 __tests__ 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
📚 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.jsonpackages/babel-plugin-transform-solid-jsx/vitest.config.ts
📚 Learning: 2025-08-25T22:16:50.118Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json:2356-2356
Timestamp: 2025-08-25T22:16:50.118Z
Learning: The file `packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json` is auto-generated by the post-build script `packages/taro-platform-h5/scripts/post-build.mjs`, which copies content from `taro-platform-h5/dist/definition.json`. This file should not be manually edited.
Applied to files:
packages/babel-plugin-transform-solid-jsx/vitest.config.ts
⏰ 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 Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (1)
packages/babel-plugin-transform-solid-jsx/vitest.config.ts (1)
1-12: 配置结构正确,coverage 提供程序默认为 v8Vitest 配置符合 v4 迁移要求:
- 未指定
coverage.provider时默认使用 v8,与根目录 package.json 中的@vitest/coverage-v8依赖一致environment: 'jsdom'适用于浏览器环境测试globals: true启用全局测试 API
There was a problem hiding this 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
🧹 Nitpick comments (1)
packages/taro-vite-runner/src/mini/style.ts (1)
28-28: 类型断言安全。使用类型断言访问内部 API 时,建议添加运行时检查以提高健壮性。
考虑应用以下改进:
- const importedCss = (chunk as ExtendedOutputChunk).viteMetadata?.importedCss + const extendedChunk = chunk as ExtendedOutputChunk + const importedCss = extendedChunk.viteMetadata?.importedCss if (importedCss && importedCss.size > 0) {这样可以提高代码可读性,便于调试。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
packages/taro-vite-runner/package.json(1 hunks)packages/taro-vite-runner/src/h5/config.ts(2 hunks)packages/taro-vite-runner/src/h5/mpa.ts(1 hunks)packages/taro-vite-runner/src/mini/style.ts(2 hunks)packages/taro/package.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/taro/package.json
🧰 Additional context used
🧠 Learnings (5)
📓 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 中依赖提升的标准做法。
Learnt from: ianzone
Repo: NervJS/taro PR: 17842
File: packages/jest-helper/tsconfig.json:9-9
Timestamp: 2025-06-23T00:09:31.233Z
Learning: 在 jest-helper 包中,src 目录下没有 __tests__ 测试目录,只包含 resolver.ts、sequencer.ts 和 snapshot 目录。不要假设包中存在测试目录结构。
📚 Learning: 2025-08-25T22:16:50.118Z
Learnt from: ianzone
Repo: NervJS/taro PR: 18150
File: packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json:2356-2356
Timestamp: 2025-08-25T22:16:50.118Z
Learning: The file `packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json` is auto-generated by the post-build script `packages/taro-platform-h5/scripts/post-build.mjs`, which copies content from `taro-platform-h5/dist/definition.json`. This file should not be manually edited.
Applied to files:
packages/taro-vite-runner/src/h5/mpa.tspackages/taro-vite-runner/src/h5/config.ts
📚 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-vite-runner/package.json
📚 Learning: 2025-05-25T18:02:31.387Z
Learnt from: ianzone
Repo: NervJS/taro PR: 17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
Applied to files:
packages/taro-vite-runner/package.jsonpackages/taro-vite-runner/src/h5/config.ts
📚 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-vite-runner/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 - x86_64-pc-windows-msvc
- 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-apple-darwin
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
🔇 Additional comments (4)
packages/taro-vite-runner/package.json (1)
60-60: 依赖管理合理。将
terser保留在devDependencies中是合理的,因为:
- Line 21 的
@rollup/plugin-terser依赖于terser包vite已正确移至peerDependencies(line 65)这符合 monorepo 中的依赖提升策略。根据已有的学习记录,Vitest 相关依赖由根目录统一管理。
packages/taro-vite-runner/src/h5/config.ts (2)
131-131: 类型守卫增强了类型安全。新增的运行时类型检查确保
middlewareMode只在值为'ssr'或'html'字符串时才被赋值,有效防止了类型错误和潜在的运行时异常。
266-276: transformIndexHtml API 迁移已正确适配 Vite ^4,两处实现保持一致。Vite v4 及更高版本(包括 v7)使用
order和handler替代了 Vite v3 的enforce和transform方式。代码审查中的变更符合此要求:
- ✓
peerDependencies声明vite: ^4- ✓ config.ts(266-276 行):
order: 'pre'+handler(html)— Vite v4+ 标准 API- ✓ mpa.ts(140-161 行):
order: 'pre'+handler(html, ctx)— 两处实现一致额外发现:这两个文件中还存在其他使用旧 API 的钩子,未进行迁移:
- config.ts 第 175 行:插件对象上的
enforce: 'pre'(属于 taro:vite-h5-config 插件)- mpa.ts 第 72 行:插件对象上的
enforce: 'pre'(属于 taro:vite-h5-mpa 插件)这些可能是独立的迁移工作项,建议确认是否需要同步更新以保持代码现代化一致性。
packages/taro-vite-runner/src/h5/mpa.ts (1)
140-161: API 迁移保持一致性。
transformIndexHtml钩子的更新与 packages/taro-vite-runner/src/h5/config.ts (lines 266-276) 中的变更保持一致:
enforce: 'pre'→order: 'pre'transform→handler这确保了整个代码库中 Vite API 使用的统一性。请参考前面对 config.ts 的审查意见,确认此 API 变更与目标 Vite 版本兼容。
| // 扩展 OutputChunk 类型以包含 viteMetadata(Vite 内部使用) | ||
| interface ExtendedOutputChunk extends OutputChunk { | ||
| viteMetadata?: { | ||
| importedCss?: Set<string> | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
验证 Vite 内部 API 的稳定性。
新增的 ExtendedOutputChunk 类型用于访问 Vite 的内部属性 viteMetadata,这是一个未公开的内部 API。虽然当前实现可以工作,但存在以下风险:
- Vite 内部 API 可能在不同版本间发生变化,导致代码失效
- 缺乏类型安全保障和官方文档支持
请运行以下脚本验证 Vite 文档中是否有公开的 API 可以替代访问 viteMetadata.importedCss:
如果这是必须使用的内部 API,建议:
- 添加版本兼容性测试
- 在代码注释中明确标注 Vite 版本依赖
- 考虑添加防御性检查或降级方案
🌐 Web query:
Vite 4.x OutputChunk viteMetadata importedCss public API documentation
💡 Result:
Short answer: viteMetadata.importedCss is an internal Vite-added property on Rollup OutputChunk (not a Rollup public API). During Vite 4 builds Vite attaches a viteMetadata object to chunks that can include an importedCss array (the CSS asset ids/files associated with that chunk). It's used by Vite internals and many plugins to find which CSS files belong to a chunk (e.g. for injecting CSS in library builds), but it is not documented as a stable public API in the official Vite docs — treat it as internal and likely to change between versions. [1][2][3]
Sources
- Vite source (build plugin code showing viteMetadata usage). [1]
- Example plugin README referencing viteMetadata.importedCss and how plugins rely on it. [2]
- Vite 4 docs (Plugin API / build docs — Vite docs do not list viteMetadata as a public Rollup API). [3]
If you want, I can paste the exact source lines from the Vite repo (file+line) and show a quick example of a plugin using chunk.viteMetadata.importedCss.
我需要检查代码库中使用的 Vite 版本以及是否已有防御性措施。
🏁 Script executed:
#!/bin/bash
# 检查 Vite 版本依赖和相关防御性代码
echo "=== 检查 Vite 版本依赖 ==="
fd -e json "package.json" -x cat {} \; | grep -A 2 -B 2 '"vite"' | head -20
echo ""
echo "=== 检查 style.ts 文件及周围代码 ==="
fd -e ts -p "style\.ts" packages/taro-vite-runner/src/mini | head -5
echo ""
echo "=== 检查是否有版本检查或防御性代码 ==="
rg -n "viteMetadata|importedCss" --type=ts -C 5Length of output: 3930
需要添加 Vite 版本兼容性声明和更完善的防御机制。
Vite 的 viteMetadata.importedCss 是内部未公开 API,未在官方文档中列出为稳定公开 API。
虽然代码已使用了可选链操作符和空值检查进行基本防御,但存在以下不足:
- 缺少版本注释:未在代码中明确标注 Vite 4.2.0+ 的版本依赖
- 无版本检查逻辑:缺乏运行时的 Vite 版本验证
- 未来升级风险:Vite 5.x+ 可能改变或移除此内部 API
建议改进:
- 在接口/函数顶部添加注释明确标注
// 依赖 Vite 4.x 内部 API, 升级 Vite 5+ 时需重评 - 添加运行时版本检查或 try-catch 防御
- 记录备选方案以便未来迁移
🤖 Prompt for AI Agents
In packages/taro-vite-runner/src/mini/style.ts around lines 7 to 12, the
ExtendedOutputChunk declaration relies on Vite's internal
viteMetadata.importedCss without documenting or defending against breaking
changes; add a top-of-file comment like "// 依赖 Vite 4.x 内部 API, 升级 Vite 5+
时需重评", implement a runtime guard that detects Vite's version (read from
process.env.npm_package_dependencies or require('vite/package.json').version)
and conditionally uses viteMetadata only for >=4.2.0 (fallback otherwise), wrap
accesses to viteMetadata.importedCss in try-catch with a clear logger
warning/information about falling back, and include a short TODO note describing
alternative approaches for Vite 5+ migration.
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
Chores
Tests