Skip to content

Conversation

@ianzone
Copy link
Contributor

@ianzone ianzone commented Aug 8, 2025

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

这个 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

  • 新功能
    • 新增按框架划分的组件库包(React/Solid/Vue3),提供 dist 导出与子路径 component-lib,便于直接引用。
  • 重构
    • 全面将原 @tarojs/components/lib/* 导入切换为 @tarojs/components-library-*;平台与组件入口、别名与加载器路径同步更新。
    • 移除 PullDownRefresh/PullToRefresh 导出(如适用)。
  • 杂务
    • 统一输出至 dist,简化构建与清理脚本;在相关平台包中加入新的组件库依赖。
  • 测试
    • 更新别名以匹配新包名。

@coderabbitai
Copy link

coderabbitai bot commented Aug 8, 2025

Walkthrough

该变更将组件库从旧路径 @tarojs/components/lib/* 迁移到新包 @tarojs/components-library-*(react/solid/vue3),统一产物目录为 dist,并调整打包配置、TS 输出、脚本与别名解析。平台侧(H5 与 Harmony Hybrid)更新了组件适配器与别名映射,测试与类型声明随之同步。

Changes

Cohort / File(s) Summary
Library pkg.json 迁移
packages/taro-components-library-react/package.json, packages/taro-components-library-solid/package.json, packages/taro-components-library-vue3/package.json
去除 private,新增 files:["dist"],main 改为 ./dist/index.js;新增 exports("." 与 "./component-lib" 子路径);脚本 prebuild 切换到 fix.cjs;clean 改为清理 dist;Vue3 包新增 engines/deps/peerDeps/devDeps。
Library 构建输出目录
packages/taro-components-library-react/rollup.config.mjs, packages/taro-components-library-solid/rollup.config.mjs, packages/taro-components-library-vue3/rollup.config.mjs
Rollup 输出目录由 ../taro-components/lib/* 改为 dist。
Library TS 输出目录
packages/taro-components-library-react/tsconfig.json, packages/taro-components-library-solid/tsconfig.json, packages/taro-components-library-vue3/tsconfig.json
新增 outDir:"./dist",移除 declarationDir(原指向 ../taro-components/lib/*)。
Library 修复脚本
packages/taro-components-library-react/scripts/fix.cjs, packages/taro-components-library-solid/scripts/fix.cjs, packages/taro-components-library-vue3/scripts/fix.cjs
读取源由 node_modules 内 @tarojs/components/dist/lib/*/components.ts,写回到本地 src/components.ts;逻辑不变。
组件总入口(React/Solid)
packages/taro-components-react/src/index.react.ts, packages/taro-components-react/src/index.solid.ts
批量将 re-export 源从 @tarojs/components/lib/(react
React 包依赖调整
packages/taro-components-react/package.json
新增依赖 @tarojs/components-library-react 与 @tarojs/components-library-solid(workspace:*)。
类型声明别名
packages/taro-components-react/types/global.d.ts, packages/taro-platform-harmony-hybrid/types/component.d.ts
模块声明从 '@tarojs/components/lib/(react
组件源包精简与构建脚本
packages/taro-components/package.json
files 去除 "lib";构建脚本收敛为 stencil build(prod/build/dev:components 简化);删除 generate:lib 等旧脚本。
Stencil 代理输出路径
packages/taro-components/scripts/stencil/stencil.config.ts
React/Vue3/Solid 输出的 proxiesFile 改为包内 dist/lib/*/components.ts;注释微调。
H5 平台:适配器与别名
packages/taro-platform-h5/src/program.ts, packages/taro-platform-h5/package.json
新增依赖三库;componentLibrary 解析改为 @tarojs/components-library-* 与特例分支;移除通用 componentAdapter,新增 componentAdapterReact/Solid/Vue3;Webpack/Vite alias 与 Vue3 loader 路径更新为新库。
Harmony Hybrid:适配器与别名
packages/taro-platform-harmony-hybrid/src/program.ts, packages/taro-platform-harmony-hybrid/package.json
新增依赖三库;componentLibrary 在老适配器分支改为新库路径;移除通用 componentAdapter,新增三种适配器;Webpack alias 与 Vue3 loader 路径更新。
Harmony Hybrid 组件入口
packages/taro-platform-harmony-hybrid/src/components/react/index.ts, packages/taro-platform-harmony-hybrid/src/components/vue3/index.ts
所有导出源从旧 lib 路径迁至新 components-library-*;末尾分组导出顺序微调;签名不变。
测试别名调整
tests/__tests__/utils/compiler.ts
Web 平台下别名从 '@tarojs/components/lib/(react

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as User App
  participant Bundler as Bundler (Webpack/Vite)
  participant H5 as H5 Program
  participant Lib as @tarojs/components-library-*
  participant Runtime as ./runtime/components (fallback)

  App->>Bundler: import from @tarojs/components
  Bundler->>H5: resolve alias(@tarojs/components$)
  alt useDeprecatedAdapterComponent
    H5-->>Bundler: @tarojs/components-library-*/component-lib
    Bundler->>Lib: load component-lib
  else useHtmlComponents & framework==react/solid
    opt solid special-case
      H5-->>Bundler: @tarojs/components-react/dist/solid
      Bundler->>Lib: load solid adapter
    end
    H5-->>Bundler: ./runtime/components (others)
    Bundler->>Runtime: load runtime components
  else default
    H5-->>Bundler: @tarojs/components-library-*
    Bundler->>Lib: load framework adapter
  end
Loading
sequenceDiagram
  autonumber
  participant Stencil as Stencil Build
  participant TC as @tarojs/components
  participant Proxy as proxiesFile (dist/lib/*/components.ts)
  participant Library as components-library-*
  Stencil->>TC: build web components
  Stencil->>Proxy: generate framework proxies
  Library->>Proxy: export index/component-lib via dist
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • yoyo837
  • tutuxxx
  • luckyadam

Poem

我在代码田里蹦三下,跳两下,
把 lib 的小径换成 dist 的家。
三路适配分开啦,别名不再挤成一团花。
H5 风轻,Harmony 云霞,
组件齐整,胡萝卜也笑成了丫(•ᴗ•)🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题“fix(taro-components): 组件与各lib解耦”简洁明了地表达了本 PR 的主要目的——将组件与各框架相关的 lib 解耦/迁移为独立的 components-library 包。该表述与变更摘要中大量路径、package.json、构建输出和别名改动高度一致,既不冗长也未概括过度,便于在提交历史中快速识别主要变更。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c055103 and 4a4e6e2.

📒 Files selected for processing (8)
  • 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-react/types/global.d.ts (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 (8)
  • packages/taro-components-library-vue3/package.json
  • packages/taro-components-react/types/global.d.ts
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/taro-components-library-react/package.json
  • packages/taro-components-react/package.json
  • packages/taro-components/package.json
  • packages/taro-platform-h5/package.json
  • packages/taro-components-library-solid/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-unknown-linux-gnu
  • 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-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi

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.

@coderabbitai coderabbitai bot requested review from luckyadam and tutuxxx August 8, 2025 05:52
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

🧹 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

📥 Commits

Reviewing files that changed from the base of the PR and between ae19ce5 and 96b5a43.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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.mjs
  • packages/taro-components-library-react/tsconfig.json
  • packages/taro-components-library-vue3/rollup.config.mjs
  • packages/taro-components-library-solid/rollup.config.mjs
  • packages/taro-components-library-solid/tsconfig.json
  • packages/taro-components-library-vue3/tsconfig.json
  • packages/taro-components/scripts/stencil/stencil.config.ts
  • packages/taro-components-library-vue3/package.json
  • packages/taro-components-library-solid/package.json
  • packages/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.mjs
  • packages/taro-components-library-react/tsconfig.json
  • tests/__tests__/utils/compiler.ts
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/taro-components-library-vue3/rollup.config.mjs
  • packages/taro-components-library-solid/rollup.config.mjs
  • packages/taro-components-library-solid/tsconfig.json
  • packages/taro-components-library-vue3/tsconfig.json
  • packages/taro-components-react/package.json
  • packages/taro-components/scripts/stencil/stencil.config.ts
  • packages/taro-components/package.json
  • packages/taro-platform-harmony-hybrid/types/component.d.ts
  • packages/taro-components-react/src/index.solid.ts
  • packages/taro-components-react/types/global.d.ts
  • packages/taro-components-library-vue3/package.json
  • packages/taro-platform-harmony-hybrid/src/components/react/index.ts
  • packages/taro-components-library-solid/package.json
  • packages/taro-components-react/src/index.react.ts
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/src/program.ts
  • packages/taro-components-library-react/package.json
  • packages/taro-platform-harmony-hybrid/src/components/vue3/index.ts
  • packages/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.mjs
  • packages/taro-components-library-react/tsconfig.json
  • tests/__tests__/utils/compiler.ts
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/taro-components-library-vue3/rollup.config.mjs
  • packages/taro-components-library-solid/rollup.config.mjs
  • packages/taro-components-library-solid/tsconfig.json
  • packages/taro-components-library-vue3/tsconfig.json
  • packages/taro-components-react/package.json
  • packages/taro-components/scripts/stencil/stencil.config.ts
  • packages/taro-components/package.json
  • packages/taro-platform-harmony-hybrid/types/component.d.ts
  • packages/taro-components-library-vue3/package.json
  • packages/taro-platform-harmony-hybrid/src/components/react/index.ts
  • packages/taro-components-library-solid/package.json
  • packages/taro-components-react/src/index.react.ts
  • packages/taro-platform-h5/package.json
  • packages/taro-components-library-react/package.json
  • packages/taro-platform-harmony-hybrid/src/components/vue3/index.ts
  • packages/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.ts
  • packages/taro-components/scripts/stencil/stencil.config.ts
  • packages/taro-components-library-solid/package.json
  • packages/taro-components-library-react/package.json
  • packages/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 的输出保持一致 👍。
请确认:

  1. package.jsontypes/exports 字段已指向 dist 内的声明文件;
  2. 发布脚本或 .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-idslot 属性在主流小程序 / Harmony 规范中并不常见:

  • marker-id 通常出现在 map 组件;
  • slot 关键字容易与组件插槽语义混淆。

请确认这些字段确实受端上支持,并在文档中留痕,否则可能导致运行时报「未知属性」警告。

packages/babel-plugin-transform-taroapi/__tests__/__mocks__/h5-definition.json (1)

356-356: 新增的滚动视图属性定义正确

scroll-view 组件添加 enhancedshowScrollbar 属性定义是合理的,这些布尔类型属性与组件库重构后的增强功能保持一致。

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(componentAdapterReactcomponentAdapterSolidcomponentAdapterVue3)替代通用的 componentAdapter getter是一个很好的架构改进:

  • 提供了更明确的框架特定解析
  • 支持新的独立组件库包结构
  • 提高了代码的可读性和维护性

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: 框架特定的组件适配器实现得当

将原来单一的 componentAdapter getter 拆分为三个框架特定的 getter (componentAdapterReactcomponentAdapterSolidcomponentAdapterVue3) 是正确的设计,提供了更清晰的框架隔离。


123-125: Webpack 别名配置完整

为每个框架组件库添加了明确的 webpack 别名配置,确保构建时能正确解析到对应的框架组件库。$ 后缀的使用是正确的 webpack 别名精确匹配语法。


147-147: Vue3 组件加载器路径更新正确

Vue3 框架下的组件加载器导入路径已正确更新为 @tarojs/components-library-vue3/components-loader,与新的包结构一致。

Also applies to: 214-214

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 96b5a43 and 36184dc.

📒 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.cjs
  • packages/taro-components-library-react/scripts/fix.cjs
  • packages/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.cjs
  • packages/taro-components-library-react/scripts/fix.cjs
  • packages/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.cjs
  • packages/taro-components-library-react/scripts/fix.cjs
  • packages/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
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.97%. Comparing base (9523842) to head (00698f8).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #18150   +/-   ##
=======================================
  Coverage   55.97%   55.97%           
=======================================
  Files         416      416           
  Lines       21560    21560           
  Branches     5289     5287    -2     
=======================================
  Hits        12069    12069           
- Misses       8002     8045   +43     
+ Partials     1489     1446   -43     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/__tests__/utils/compiler.ts 100.00% <100.00%> (ø)

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ianzone ianzone mentioned this pull request Aug 9, 2025
1 task
@ianzone
Copy link
Contributor Author

ianzone commented Oct 27, 2025

这个PR还有人跟进吗?

This was referenced Nov 1, 2025
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.

2 participants