-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(taro-components): 组件与各lib解耦 #18150
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将组件包从旧路径 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as 应用
participant Bundler as 打包器 (Webpack/Vite)
participant Program as Platform Program (H5/Harmony)
participant Lib as `@tarojs/components-library-`*
participant Runtime as ./runtime/components
App->>Bundler: import '@tarojs/components' / 子路径
Bundler->>Program: 解析别名与适配器
alt useDeprecatedAdapterComponent
Program-->>Bundler: resolve -> Lib/component-lib
Bundler->>Lib: 加载 component-lib 入口
else useHtmlComponents & framework==react/solid
Program-->>Bundler: resolve -> `@tarojs/components-react/dist/solid` (special)
Bundler->>Lib: 加载 framework 特殊适配器
else fallback
Program-->>Bundler: resolve -> ./runtime/components
Bundler->>Runtime: 加载运行时组件
end
sequenceDiagram
autonumber
participant Stencil as Stencil
participant TC as `@tarojs/components`
participant Proxy as proxiesFile (dist/lib/*/components.ts)
participant Lib as components-library-*
Stencil->>TC: 构建 web 组件并生成代理
Stencil->>Proxy: 写入 dist/lib/*/components.ts
Lib->>Proxy: 使用 dist 中的 proxiesFile 作为 framework 入口
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 需重点关注:
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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
🧹 Nitpick comments (4)
packages/taro-platform-h5/package.json (1)
45-48: 新增组件库依赖与旧依赖并存,可能造成冗余已添加三条
components-library-*依赖,但仍保留@tarojs/components-react。
若平台仅依赖新包,可考虑移除旧包,减小安装体积并避免版本漂移。- "@tarojs/components-react": "workspace:*",请确认两套依赖并存是否确有必要。
packages/taro-components-library-react/tsconfig.json (1)
4-6: 建议排除编译产物目录,避免二次编译污染新增
outDir: "./dist"后,编译输出会落到工作目录内。如果上层tsconfig.root.json没有显式排除dist,增量编译或 IDE 可能把生成的.d.ts/.js再次当作输入文件,造成「重复声明」或「莫名语法错误」。
建议在当前tsconfig.json里加入"exclude": ["dist"]或确认根
tsconfig已全局排除。packages/taro-platform-harmony-hybrid/package.json (1)
43-45: 依赖重复,可能引入两套组件实现当前包同时依赖
@tarojs/components-react(旧包)@tarojs/components-library-react(新包)若两者同时被打包,可能出现组件实现冲突或包体积膨胀。建议:
- "@tarojs/components": "workspace:*", - "@tarojs/components-react": "workspace:*", + // 保留需要的一个版本即可请确认运行时只会加载一套组件库。
packages/taro-components-react/package.json (1)
41-42: React 组件包不应硬依赖 Solid 组件库
@tarojs/components-react引入@tarojs/components-library-solid会让未使用 Solid 的项目额外安装一套依赖,增加体积与安装时间。除非确有跨框架渲染需求,建议移除:- "@tarojs/components-library-solid": "workspace:*",确保 peer/optional 关系正确即可。
📜 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 (25)
packages/babel-plugin-transform-taroapi/__tests__/__mocks__/h5-definition.json(2 hunks)packages/taro-components-library-react/package.json(1 hunks)packages/taro-components-library-react/rollup.config.mjs(1 hunks)packages/taro-components-library-react/tsconfig.json(1 hunks)packages/taro-components-library-solid/package.json(1 hunks)packages/taro-components-library-solid/rollup.config.mjs(1 hunks)packages/taro-components-library-solid/tsconfig.json(1 hunks)packages/taro-components-library-vue3/package.json(1 hunks)packages/taro-components-library-vue3/rollup.config.mjs(1 hunks)packages/taro-components-library-vue3/tsconfig.json(1 hunks)packages/taro-components-react/package.json(1 hunks)packages/taro-components-react/src/index.react.ts(1 hunks)packages/taro-components-react/src/index.solid.ts(1 hunks)packages/taro-components-react/types/global.d.ts(1 hunks)packages/taro-components/package.json(1 hunks)packages/taro-components/scripts/stencil/stencil.config.ts(3 hunks)packages/taro-platform-h5/package.json(1 hunks)packages/taro-platform-h5/src/program.ts(5 hunks)packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json(1 hunks)packages/taro-platform-harmony-hybrid/package.json(1 hunks)packages/taro-platform-harmony-hybrid/src/components/react/index.ts(2 hunks)packages/taro-platform-harmony-hybrid/src/components/vue3/index.ts(2 hunks)packages/taro-platform-harmony-hybrid/src/program.ts(6 hunks)packages/taro-platform-harmony-hybrid/types/component.d.ts(1 hunks)tests/__tests__/utils/compiler.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: ianzone
PR: NervJS/taro#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 文件。
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
📚 Learning: 2025-07-22T09:16:21.180Z
Learnt from: ianzone
PR: NervJS/taro#18056
File: packages/taro-runtime/tsconfig.json:10-10
Timestamp: 2025-07-22T09:16:21.180Z
Learning: 在使用 rollup-plugin-dts 的项目中,rollup.config.ts 等构建配置文件会被自动排除,不需要在 tsconfig.json 中手动排除。
Applied to files:
packages/taro-components-library-react/rollup.config.mjspackages/taro-components-library-react/tsconfig.jsonpackages/taro-components-library-vue3/rollup.config.mjspackages/taro-components-library-solid/rollup.config.mjspackages/taro-components-library-solid/tsconfig.jsonpackages/taro-components-library-vue3/tsconfig.jsonpackages/taro-components/scripts/stencil/stencil.config.tspackages/taro-components-library-vue3/package.jsonpackages/taro-components-library-solid/package.jsonpackages/taro-components-library-react/package.json
📚 Learning: 2025-05-25T18:02:31.387Z
Learnt from: ianzone
PR: NervJS/taro#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-components-library-react/rollup.config.mjspackages/taro-components-library-react/tsconfig.jsontests/__tests__/utils/compiler.tspackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-vue3/rollup.config.mjspackages/taro-components-library-solid/rollup.config.mjspackages/taro-components-library-solid/tsconfig.jsonpackages/taro-components-library-vue3/tsconfig.jsonpackages/taro-components-react/package.jsonpackages/taro-components/scripts/stencil/stencil.config.tspackages/taro-components/package.jsonpackages/taro-platform-harmony-hybrid/types/component.d.tspackages/taro-components-react/src/index.solid.tspackages/taro-components-react/types/global.d.tspackages/taro-components-library-vue3/package.jsonpackages/taro-platform-harmony-hybrid/src/components/react/index.tspackages/taro-components-library-solid/package.jsonpackages/taro-components-react/src/index.react.tspackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/src/program.tspackages/taro-components-library-react/package.jsonpackages/taro-platform-harmony-hybrid/src/components/vue3/index.tspackages/taro-platform-h5/src/program.ts
📚 Learning: 2025-08-08T02:32:58.207Z
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Applied to files:
packages/taro-components-library-react/rollup.config.mjspackages/taro-components-library-react/tsconfig.jsontests/__tests__/utils/compiler.tspackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-vue3/rollup.config.mjspackages/taro-components-library-solid/rollup.config.mjspackages/taro-components-library-solid/tsconfig.jsonpackages/taro-components-library-vue3/tsconfig.jsonpackages/taro-components-react/package.jsonpackages/taro-components/scripts/stencil/stencil.config.tspackages/taro-components/package.jsonpackages/taro-platform-harmony-hybrid/types/component.d.tspackages/taro-components-library-vue3/package.jsonpackages/taro-platform-harmony-hybrid/src/components/react/index.tspackages/taro-components-library-solid/package.jsonpackages/taro-components-react/src/index.react.tspackages/taro-platform-h5/package.jsonpackages/taro-components-library-react/package.jsonpackages/taro-platform-harmony-hybrid/src/components/vue3/index.tspackages/taro-platform-h5/src/program.ts
📚 Learning: 2025-06-23T00:09:31.233Z
Learnt from: ianzone
PR: NervJS/taro#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 目录。不要假设包中存在测试目录结构。
Applied to files:
tests/__tests__/utils/compiler.tspackages/taro-components/scripts/stencil/stencil.config.tspackages/taro-components-library-solid/package.jsonpackages/taro-components-library-react/package.jsonpackages/taro-platform-h5/src/program.ts
📚 Learning: 2025-05-06T06:55:44.077Z
Learnt from: Single-Dancer
PR: NervJS/taro#17653
File: packages/taro-components-advanced/src/components/water-flow/node.ts:83-95
Timestamp: 2025-05-06T06:55:44.077Z
Learning: 在 Taro 的 getRectSizeSync 函数中,如果找不到指定的节点,函数会一直处于 pending 状态而不是抛出错误。在这种情况下,使用 try/catch 处理不够充分,需要添加超时处理如 Promise.race 来避免无限等待。
Applied to files:
packages/taro-platform-harmony-hybrid/src/program.ts
📚 Learning: 2025-07-11T14:04:05.557Z
Learnt from: ianzone
PR: NervJS/taro#17993
File: .github/advanced-issue-labeler.yml:20-63
Timestamp: 2025-07-11T14:04:05.557Z
Learning: 在 NervJS/taro 项目的 .github/advanced-issue-labeler.yml 中,平台标签被设计为可以多个共存。当用户选择"所有平台"时,系统会同时应用多个平台标签(如 T-h5, T-rn, T-weapp 等),这是期望的行为而非冲突。同样,"所有小程序"也会为小程序相关的标签应用多个标签。这种设计有助于跨平台问题的管理和维护者关注。
Applied to files:
packages/taro-platform-harmony-hybrid/src/program.ts
🧬 Code Graph Analysis (1)
packages/taro-components/scripts/stencil/stencil.config.ts (1)
packages/taro-components/scripts/stencil/output-target/index.ts (1)
solidOutputTarget(106-120)
⏰ 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-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 (32)
packages/taro-components-library-solid/tsconfig.json (1)
5-5: outDir 调整已对齐 Rollup 配置,但请同步检查类型入口
outDir改为./dist与 rollup 的输出保持一致 👍。
请确认:
package.json的types/exports字段已指向dist内的声明文件;- 发布脚本或
.npmignore未误排除dist。packages/taro-components-library-vue3/rollup.config.mjs (1)
10-15: 确认已移除旧路径引用 @tarojs/components/lib/vue3在仓库中运行
rg -n "@tarojs/components/lib/vue3"未发现任何匹配,旧引用已清除,无需进一步操作。
packages/taro-components-library-react/rollup.config.mjs (1)
10-15: 请确认已清理旧的@tarojs/components/lib/react引用
我在项目中运行了以下命令,未发现任何相关引用:rg -n "@tarojs/components/lib/react" || true请手动检查是否存在别名导入或动态引用,确保代码库不再依赖旧组件。
packages/taro-components-library-solid/rollup.config.mjs (1)
10-15: dist 目录调整已就绪,注意 alias 配置同步输出目录改为
dist与 tsconfig 对齐 👍。
请同时检查所有 webpack / vite alias 是否已从旧路径更新至@tarojs/components-library-solid,避免运行期解析失败。packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json (1)
2175-2178: 确认属性是否符合规范为
cover-view新增的marker-id与slot属性在主流小程序 / Harmony 规范中并不常见:
marker-id通常出现在map组件;slot关键字容易与组件插槽语义混淆。请确认这些字段确实受端上支持,并在文档中留痕,否则可能导致运行时报「未知属性」警告。
packages/babel-plugin-transform-taroapi/__tests__/__mocks__/h5-definition.json (1)
356-356: 新增的滚动视图属性定义正确为
scroll-view组件添加enhanced和showScrollbar属性定义是合理的,这些布尔类型属性与组件库重构后的增强功能保持一致。Also applies to: 366-366
packages/taro-components-library-vue3/tsconfig.json (1)
5-5: 输出目录配置正确将
outDir设置为"./dist"符合组件库解耦的目标,确保每个组件库包都有独立的构建输出目录,提高了包的隔离性。tests/__tests__/utils/compiler.ts (1)
60-61: 测试别名配置更新正确将组件库别名从旧的
@tarojs/components/lib/*命名空间更新为新的@tarojs/components-library-*命名空间,确保测试环境与重构后的包结构保持一致。packages/taro-components-react/src/index.solid.ts (1)
2-78: 组件导入路径迁移完整且正确所有从
@tarojs/components/lib/solid导入的组件已正确迁移到@tarojs/components-library-solid,本地组件导出保持不变。这完全符合组件库解耦的目标。packages/taro-components-react/types/global.d.ts (1)
7-13: 类型声明更新正确模块声明从旧的
@tarojs/components/lib/*命名空间正确迁移到新的@tarojs/components-library-*命名空间,同时保持了从@tarojs/components的重新导出,确保类型兼容性。packages/taro-components/scripts/stencil/stencil.config.ts (2)
15-15: LGTM! 构建输出路径调整符合解耦目标将 proxiesFile 路径从外部包源码目录 (
../taro-components-library-*/src/components.ts) 调整为本地构建输出目录 (dist/lib/*/components.ts),与组件库解耦的 PR 目标一致。Also applies to: 34-34, 40-40
92-93: LGTM! 注释格式优化注释中的格式调整提高了可读性。
packages/taro-platform-harmony-hybrid/types/component.d.ts (1)
8-8: LGTM! 模块声明更新符合新的包结构将模块声明从
@tarojs/components/lib/*更新为独立的@tarojs/components-library-*包,确保类型声明与新的组件库解耦结构保持一致。Also applies to: 12-12
packages/taro-components-react/src/index.react.ts (1)
7-76: LGTM! 系统性迁移到新的组件库包所有组件导出已从
@tarojs/components/lib/react迁移到独立的@tarojs/components-library-react包,实现了组件库的完全解耦。本地组件导出(如 Button、Icon 等)保持不变,确保向后兼容性。packages/taro-platform-harmony-hybrid/src/components/react/index.ts (1)
1-82: LGTM! Harmony Hybrid 平台的 React 组件导出迁移所有组件导出已系统性地从
@tarojs/components/lib/react迁移到@tarojs/components-library-react,与组件库解耦的整体架构保持一致。本地默认导出 HosMap 保持不变。packages/taro-components/package.json (2)
14-21: LGTM! 包文件清单更新符合解耦架构移除 "lib" 目录表明该包不再发布编译后的框架特定组件,与组件库解耦的设计目标一致。各框架组件现在由独立的
@tarojs/components-library-*包负责。
25-29: LGTM! 构建脚本简化合理构建脚本的简化反映了包职责的变化:不再需要复杂的多框架构建流程,专注于核心组件构建。移除的脚本(build:ci、build:library、dev:library-* 等)现在由各自独立的组件库包处理。
packages/taro-components-library-vue3/package.json (2)
7-17: 包结构标准化改进,符合解耦目标这些更改正确地实现了组件库的解耦:
- 移除
private字段使包可发布- 更新主入口点到
./dist/index.js- 添加标准的
exports字段支持现代模块解析- 提供了两个导出路径:根路径和组件库子路径
配置符合 Node.js 包导出标准且与其他框架库保持一致。
20-22: 构建脚本优化合理
prebuild脚本从fix.js改为fix.cjs,可能是为了更好的 CommonJS 兼容性clean脚本从相对路径改为本地dist目录,符合新的输出结构这些更改与包的解耦目标一致。
packages/taro-components-library-solid/package.json (2)
5-15: Solid 组件库配置与其他框架库保持一致配置更改与 Vue3 和 React 组件库完全一致:
- 移除
private字段- 主入口点标准化为
./dist/index.js- 添加现代
exports字段- 支持根路径和
./component-lib子路径导出这种一致性有利于维护和使用。
17-19: 构建脚本更新合理构建相关脚本的更改与其他组件库保持一致,支持新的本地构建输出结构。
packages/taro-platform-harmony-hybrid/src/components/vue3/index.ts (1)
1-82: Vue3 组件导出路径系统性迁移完成所有组件导出已成功从
@tarojs/components/lib/vue3迁移到新的@tarojs/components-library-vue3包命名空间:
- 单个组件导出路径更新完整
- 分组导出也已相应调整
- 注释的 Tabbar/TabItem 导出也保持了路径一致性
这种系统性迁移完美支持了组件与各库的解耦目标。
packages/taro-components-library-react/package.json (2)
7-17: React 组件库配置标准化完成配置更改与 Vue3 和 Solid 组件库完全一致:
- 移除
private字段使包可发布- 统一主入口点为
./dist/index.js- 添加标准
exports字段支持现代模块解析- 提供根路径和组件库子路径导出
三个框架组件库的一致性配置体现了良好的架构设计。
19-21: 构建流程标准化构建脚本的更改与其他组件库保持一致,支持新的解耦架构和本地输出结构。
packages/taro-platform-harmony-hybrid/src/program.ts (4)
49-49: 已弃用适配器组件路径更新正确组件库路径从
@tarojs/components/lib/${framework}/component-lib更新为@tarojs/components-library-${framework}/component-lib,与新的包结构保持一致。
55-65: 框架特定的组件适配器getter设计优秀用三个独立的getter(
componentAdapterReact、componentAdapterSolid、componentAdapterVue3)替代通用的componentAdaptergetter是一个很好的架构改进:
- 提供了更明确的框架特定解析
- 支持新的独立组件库包结构
- 提高了代码的可读性和维护性
103-105: Webpack别名配置正确更新别名配置已正确更新以使用新的组件库包:
@tarojs/components-library-react$指向 React 适配器@tarojs/components-library-solid$指向 Solid 适配器@tarojs/components-library-vue3$指向 Vue3 适配器这确保了模块解析的正确性。
127-127: Vue3组件加载器导入路径更新Vue3 components-loader 的导入路径已正确从
@tarojs/components/lib/vue3/components-loader更新为@tarojs/components-library-vue3/components-loader。packages/taro-platform-h5/src/program.ts (4)
57-60: 组件库路径更新正确新的组件库路径结构
@tarojs/components-library-${this.aliasFramework}符合解耦目标,正确支持不同框架的独立组件库包。
63-73: 框架特定的组件适配器实现得当将原来单一的
componentAdaptergetter 拆分为三个框架特定的 getter (componentAdapterReact、componentAdapterSolid、componentAdapterVue3) 是正确的设计,提供了更清晰的框架隔离。
123-125: Webpack 别名配置完整为每个框架组件库添加了明确的 webpack 别名配置,确保构建时能正确解析到对应的框架组件库。
$后缀的使用是正确的 webpack 别名精确匹配语法。
147-147: Vue3 组件加载器路径更新正确Vue3 框架下的组件加载器导入路径已正确更新为
@tarojs/components-library-vue3/components-loader,与新的包结构一致。Also applies to: 214-214
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: 3
🧹 Nitpick comments (2)
packages/taro-components-library-vue3/scripts/fix.cjs (1)
21-21: 写文件更安全:确保目录存在、仅在内容变化时写入并显式编码当前无条件覆盖写入可能导致重复构建和缓存失效。建议确保目录存在并在内容有变更时才写入,同时显式使用 'utf8'。
-fs.writeFileSync(path.resolve(__dirname, '..', 'src/components.ts'), code) +const outPath = path.resolve(__dirname, '..', 'src', 'components.ts') +// 确保目录存在(Node 内置方式,避免依赖 fs-extra 特性) +fs.mkdirSync(path.dirname(outPath), { recursive: true }) +const prev = fs.existsSync(outPath) ? fs.readFileSync(outPath, 'utf8') : null +if (prev !== code) { + fs.writeFileSync(outPath, code, 'utf8') +}packages/taro-components-library-solid/scripts/fix.cjs (1)
4-4: 路径硬编码可读性与稳健性不足直接拼接
'node_modules/@tarojs/components/dist/lib/solid/components.ts'假设了包的内部结构,未来目录调整或采用不同包管理器布局(pnpm hoist 层级变化)时容易失效。建议用require.resolve('@tarojs/components/package.json')拿到包根路径后再拼路径,或在脚本里做两种路径的回退查找,提高兼容性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
packages/taro-components-library-react/scripts/fix.cjs(2 hunks)packages/taro-components-library-solid/scripts/fix.cjs(2 hunks)packages/taro-components-library-vue3/scripts/fix.cjs(2 hunks)packages/taro-platform-h5/src/program.ts(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/taro-platform-h5/src/program.ts
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: ianzone
PR: NervJS/taro#17993
File: .github/advanced-issue-labeler.yml:20-63
Timestamp: 2025-07-11T14:04:05.557Z
Learning: 在 NervJS/taro 项目的 .github/advanced-issue-labeler.yml 中,平台标签被设计为可以多个共存。当用户选择"所有平台"时,系统会同时应用多个平台标签(如 T-h5, T-rn, T-weapp 等),这是期望的行为而非冲突。同样,"所有小程序"也会为小程序相关的标签应用多个标签。这种设计有助于跨平台问题的管理和维护者关注。
Learnt from: ianzone
PR: NervJS/taro#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 文件。
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
📚 Learning: 2025-05-25T18:02:31.387Z
Learnt from: ianzone
PR: NervJS/taro#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-components-library-vue3/scripts/fix.cjspackages/taro-components-library-react/scripts/fix.cjspackages/taro-components-library-solid/scripts/fix.cjs
📚 Learning: 2025-08-08T02:32:58.207Z
Learnt from: ianzone
PR: NervJS/taro#18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.207Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Applied to files:
packages/taro-components-library-vue3/scripts/fix.cjspackages/taro-components-library-react/scripts/fix.cjspackages/taro-components-library-solid/scripts/fix.cjs
📚 Learning: 2025-06-23T00:09:31.233Z
Learnt from: ianzone
PR: NervJS/taro#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 目录。不要假设包中存在测试目录结构。
Applied to files:
packages/taro-components-library-vue3/scripts/fix.cjspackages/taro-components-library-react/scripts/fix.cjspackages/taro-components-library-solid/scripts/fix.cjs
🧬 Code Graph Analysis (2)
packages/taro-components-library-vue3/scripts/fix.cjs (2)
packages/taro-components-library-react/scripts/fix.cjs (4)
componentsPath(4-4)path(2-2)fs(1-1)code(9-9)packages/taro-components-library-solid/scripts/fix.cjs (4)
componentsPath(4-4)path(2-2)fs(1-1)code(9-9)
packages/taro-components-library-react/scripts/fix.cjs (2)
packages/taro-components-library-solid/scripts/fix.cjs (4)
componentsPath(4-4)path(2-2)fs(1-1)code(9-9)packages/taro-components-library-vue3/scripts/fix.cjs (4)
componentsPath(4-4)path(2-2)fs(1-1)code(8-8)
⏰ 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). (2)
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (1)
packages/taro-components-library-solid/scripts/fix.cjs (1)
38-38: 写入目标路径合理输出文件重写回本地
src/components.ts符合解耦目的,没有明显问题。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18150 +/- ##
========================================
Coverage 56.33% 56.33%
========================================
Files 447 447
Lines 23342 23342
Branches 5763 5791 +28
========================================
Hits 13149 13149
- Misses 8364 8495 +131
+ Partials 1829 1698 -131
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
我没有release权限 |
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 (7)
packages/taro-components-library-react/package.json(1 hunks)packages/taro-components-library-solid/package.json(1 hunks)packages/taro-components-library-vue3/package.json(1 hunks)packages/taro-components-react/package.json(1 hunks)packages/taro-components/package.json(1 hunks)packages/taro-platform-h5/package.json(1 hunks)packages/taro-platform-harmony-hybrid/package.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/taro-components-react/package.json
- packages/taro-components-library-vue3/package.json
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
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 别名配置。
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 文件。
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: 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 中的类型兼容性。
📚 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-components-library-react/package.jsonpackages/taro-components/package.jsonpackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-solid/package.json
📚 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-components-library-react/package.jsonpackages/taro-components/package.jsonpackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-solid/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-components-library-react/package.jsonpackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-solid/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-components-library-react/package.jsonpackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-solid/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:
packages/taro-components-library-react/package.jsonpackages/taro-platform-h5/package.jsonpackages/taro-platform-harmony-hybrid/package.jsonpackages/taro-components-library-solid/package.json
📚 Learning: 2025-07-11T14:04:05.557Z
Learnt from: ianzone
Repo: NervJS/taro PR: 17993
File: .github/advanced-issue-labeler.yml:20-63
Timestamp: 2025-07-11T14:04:05.557Z
Learning: 在 NervJS/taro 项目的 .github/advanced-issue-labeler.yml 中,平台标签被设计为可以多个共存。当用户选择"所有平台"时,系统会同时应用多个平台标签(如 T-h5, T-rn, T-weapp 等),这是期望的行为而非冲突。同样,"所有小程序"也会为小程序相关的标签应用多个标签。这种设计有助于跨平台问题的管理和维护者关注。
Applied to files:
packages/taro-platform-harmony-hybrid/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). (4)
- 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 Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (7)
packages/taro-platform-h5/package.json (1)
45-47: ✓ 依赖声明与解耦目标一致三个新的组件库包声明符合 PR 中组件库解耦的目标,且版本指定器
workspace:*正确。这是实现框架无关的组件库分离所必需的。packages/taro-components-library-react/package.json (2)
22-22: 验证 prebuild 脚本文件是否存在
fix.js改为fix.cjs需要确认对应的脚本文件确实存在。请验证packages/taro-components-library-react/scripts/fix.cjs文件是否存在且功能正确。
7-20: ✓ 包导出结构符合发布要求
files、main和exports的更新遵循现代 npm 包的标准做法。双重导出支持(.和./component-lib)为消费者提供了灵活性。packages/taro-components-library-solid/package.json (1)
5-22: ✓ 与 React 包结构保持一致Solid 版本包的更新与 React 版本包完全对齐,保持了多框架实现的结构一致性。同样需要验证
packages/taro-components-library-solid/scripts/fix.cjs文件的存在。packages/taro-platform-harmony-hybrid/package.json (1)
43-45: ✓ 依赖配置符合插件源码需求三个组件库作为直接依赖(而非 peer 依赖)是正确的,因为
packages/taro-platform-harmony-hybrid/src/program.ts中的componentAdapter*getter 方法和 webpack 别名配置对这些包有直接引用。根据之前的学习,这些包必须在dependencies中以确保插件正常工作。packages/taro-components/package.json (2)
14-21: 确认从 files 数组中移除 "lib" 不会导致消费者获取失败。"lib" 的移除表明此为 breaking change -
@tarojs/components/lib/*路径将不再可用。根据 PR 说明,新的@tarojs/components-library-{react,solid,vue3}包应提供替代导出。需验证:
- 所有平台适配器和依赖者已更新为使用新的导出路径
- 构建和 CI 脚本已适配新的包结构
- 旧路径不存在遗留引用
25-25: 构建脚本简化是合理的,但需要验证 CI/CD 流程兼容性。
"prod"脚本从build:ci改为build,build脚本从多步骤流程改为单一stencil build命令。这种简化符合解耦目标。需确认:
- CI/CD 管道引用
pnpm run prod或pnpm run build的任何脚本都已适配此更改- 原有
build:ci中的任何特殊处理(如特定平台配置、特定构建标志等)未被遗漏- 开发工作流(
dev:components--watch 模式)与之前的dev:library-*脚本功能等价Also applies to: 28-29
| "prebuild": "run-p generate:*", | ||
| "prebuild:ci": "run-p generate:*", | ||
| "build:ci": "cross-env NODE_ENV=production run-s build:components", | ||
| "build": "cross-env NODE_ENV=production run-s build:components build:library", | ||
| "build:components": "stencil build", | ||
| "build:library": "pnpm --filter @tarojs/components-library-react --filter @tarojs/components-library-vue3 --filter @tarojs/components-library-solid run build", | ||
| "dev:components": "cross-env NODE_ENV=development pnpm run build:components --watch", | ||
| "dev:library-react": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-react run dev", | ||
| "dev:library-vue3": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-vue3 run dev", | ||
| "dev:library-solid": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-solid run dev", | ||
| "generate:lib": "mkdirp lib", | ||
| "build": "cross-env NODE_ENV=production stencil build", | ||
| "dev:components": "cross-env NODE_ENV=development stencil build --watch", | ||
| "generate:stencil-config": "esbuild ./scripts/stencil/stencil.config.ts --external:lightningcss --bundle --platform=node --outfile=stencil.config.js", | ||
| "sync:types": "pnpm run tsx --files scripts/json-schema-to-types.ts", |
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
验证简化后的构建流程仍能生成所有必需的类型声明。
构建脚本已简化为单一的 stencil build 命令。根据之前的审查记录,类型生成曾是关键问题。需要确认:
stencil.config.ts中的dist-custom-elements目标是否已启用generateTypeDeclarations: true,以自动生成types/index.d.tssync:types脚本(第 31 行)是否需要添加到prebuild或prepare命令中运行- 简化后的
stencil build是否确实生成以下所有产物:dist/和dist-custom-elements输出loader/产物mini/产物types/index.d.ts和vue3.d.ts
由于 package.json 声明 "types": "types/index.d.ts"(第 9 行),该文件的生成必须得到保证。
🌐 Web query:
Stencil 2.22.3 中 generateTypeDeclarations 配置选项的默认行为和 dist-custom-elements 输出目标是否自动生成 TypeScript 声明文件
💡 Result:
短答:
-
在 Stencil 2.22.3(v2 系列)中,dist-custom-elements 的 generateTypeDeclarations 默认是 false。默认情况下只有当项目同时声明了 dist 输出目标 时,才会生成 .d.ts;要让 dist-custom-elements 单独输出声明文件,需要在该输出目标上显式设置 generateTypeDeclarations: true。[1]
-
(补充)在后续的 Stencil v3/v4 文档中,该选项的默认值已变化(文档显示为默认 true),所以不同时期的默认行为不同,注意按你使用的 Stencil 版本确认。[2]
参考:Stencil 文档(v2 dist-custom-elements 节;v3/v4 相应页)。[1][2]
🏁 Script executed:
#!/bin/bash
# Locate and examine stencil.config.ts
fd -t f "stencil.config.ts" --exec cat {} \;Length of output: 0
🏁 Script executed:
#!/bin/bash
# Find and examine stencil.config.ts in scripts directory
fd -t f "stencil.config.ts" scripts/ --exec cat {} \;Length of output: 0
🏁 Script executed:
#!/bin/bash
# List scripts directory and search for stencil-related files
echo "=== Scripts directory contents ===" && ls -la scripts/ 2>/dev/null || echo "scripts/ not found"
echo -e "\n=== Searching for stencil files ===" && find . -type f -name "*stencil*" 2>/dev/null | head -20Length of output: 304
🏁 Script executed:
#!/bin/bash
# Read the stencil config file
cat ./packages/taro-components/scripts/stencil/stencil.config.tsLength of output: 4227
🏁 Script executed:
#!/bin/bash
# Check package.json for prepare hook and full scripts section
echo "=== package.json scripts and prepare hook ===" && jq '.scripts, .prepare' ./packages/taro-components/package.json
echo -e "\n=== Check json-schema-to-types.ts ===" && cat ./packages/taro-components/scripts/json-schema-to-types.ts 2>/dev/null || echo "File not found or cannot be read"Length of output: 11538
🏁 Script executed:
#!/bin/bash
# Check if types/index.d.ts exists and verify build artifacts
echo "=== Checking types directory ===" && ls -la ./packages/taro-components/types/ 2>/dev/null | head -20 || echo "types/ not found"
echo -e "\n=== Checking dist directory ===" && ls -la ./packages/taro-components/dist/ 2>/dev/null | head -10 || echo "dist/ not found"
echo -e "\n=== Check CI/build configuration ===" && find ./packages/taro-components -name "*.yml" -o -name "*.yaml" | xargs grep -l "sync:types\|stencil build" 2>/dev/null || echo "No CI config found with these patterns"Length of output: 1359
sync:types 脚本未集成到构建流程中,导致类型声明缺少平台特定注解。
验证发现核心问题未解决:
- 类型生成机制确认:stencil build 通过配置的 dist 输出目标自动生成 types/index.d.ts ✓
- 平台注解更新缺失:sync:types 脚本定义在第 31 行,但未添加到 prepare 或 prebuild 中
- prepare hook 仅运行 "run-p generate:"(只匹配 generate: 模式)
- sync:types 不符合该模式,需明确调用才能运行
- 简化的构建流程中被遗漏
json-schema-to-types.ts 的职责是读取已生成的 .d.ts 文件并添加 @supported 平台注解。该步骤应为构建流程的一部分,确保类型声明中包含小程序平台的支持信息。
需修复:将 sync:types 添加到 prepare 或 prebuild,或将其重命名为 generate:types-sync 以符合自动匹配模式。
🤖 Prompt for AI Agents
In packages/taro-components/package.json around lines 27 to 31, the "sync:types"
script is defined but not invoked by the prepare/prebuild pipeline, so generated
.d.ts files never get platform @supported annotations; fix by either adding
"sync:types" to the existing prebuild/prepare script list (e.g., include it in
"run-p generate:*" or append it to the prebuild command) or rename the script to
follow the generate:* pattern (e.g., "generate:types-sync") and update any
callers so it runs during the prepare/prebuild phase; ensure script ordering
runs after stencil build so the d.ts files exist before json-schema-to-types.ts
is executed.
这个 PR 做了什么? (简要描述所做更改)
如题
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
新功能
重构
杂务
测试
✏️ Tip: You can customize this high-level summary in your review settings.