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 输出与子路径导出,若干包从私有改为可发布。
  • 重构

    • 大量组件的导出源切换到新组件库包;平台运行时与加载器别名、导入路径按框架调整;移除部分下拉刷新导出。
  • 杂务

    • 统一构建输出为 dist,简化清理/构建脚本,更新 TypeScript/打包配置与维护脚本,新增并调整若干构建辅助脚本。
  • 测试

    • 更新测试与别名配置以匹配新的包名与路径。

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

@coderabbitai
Copy link

coderabbitai bot commented Aug 8, 2025

Walkthrough

将组件包从旧路径 @tarojs/components/lib/* 迁移到新包命名空间 @tarojs/components-library-(react|solid|vue3),统一构建产物目录为 dist,并更新相关 package.json、tsconfig、rollup、脚本、平台适配器与构建别名。

Changes

Cohort / File(s) Summary
Library package metadata
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 改为 node ./scripts/fix.cjsclean 改为 rimraf dist
Library 构建输出配置
packages/taro-components-library-*/rollup.config.mjs
Rollup 输出目录由 ../taro-components/lib/* 改为本包 dist
TypeScript 输出配置
packages/taro-components-library-*/tsconfig.json
新增 outDir: "./dist",移除指向 ../taro-components/lib/*declarationDir
Library 修复脚本
packages/taro-components-library-*/scripts/fix.cjs
读取路径改为 node_modules 内的 dist/lib/* components 文件,处理后写回本地 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
类型声明模块别名
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
从发布文件移除 lib,构建脚本收敛为 stencil build,移除多余旧脚本(generate:lib、build:ci 等)。
Stencil 代理输出路径
packages/taro-components/scripts/stencil/stencil.config.ts
proxiesFile 输出路径从外部库源改为包内 dist/lib/*/components.ts;注释微调。
H5 平台:适配器与别名
packages/taro-platform-h5/src/program.ts, packages/taro-platform-h5/package.json
componentLibrary 解析改为 @tarojs/components-library-*(含 useHtmlComponents/特殊分支),移除通用 componentAdapter,新增 framework-specific 适配器(react/solid/vue3),更新 Webpack/Vite 别名与 Vue3 loader 路径。
Harmony Hybrid:适配器与别名
packages/taro-platform-harmony-hybrid/src/program.ts, packages/taro-platform-harmony-hybrid/package.json
新增三库依赖;component-library 路径和 component-adapter 拆分为三者;Webpack alias 与 Vue3 loader 路径更新;注释格式微调。
Harmony Hybrid 组件入口
packages/taro-platform-harmony-hybrid/src/components/...
所有导出源从旧 @tarojs/components/lib/* 迁移到 @tarojs/components-library-*,导出签名不变,分组顺序有微调。
测试别名调整
tests/__tests__/utils/compiler.ts
测试内 alias 从 `@tarojs/components/lib/(react

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
Loading
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 入口
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

需重点关注:

  • packages/taro-components-react/src/index.react.ts 的大规模 re-export(核对是否遗漏或改变导出语义)。
  • H5 与 Harmony Hybrid 中的 alias/loader 路径与三套 componentAdapter 实现(program.ts)在 Webpack 与 Vite 下的一致性。
  • 各包 tsconfig.json / rollup.config.mjs / package.json 改动在 CI 发布、类型生成与 rollup 输出上的协同(declaration 路径、exports 字段)。

Possibly related PRs

Suggested reviewers

  • luckyadam
  • yoyo837
  • tutuxxx

Poem

我是爱敲键的兔子,跳进仓库的洞,
把旧的 lib 小径改成了 dist 的新公路。
三路适配分明,别名也排好队,
构建更整齐,组件安家乐业,🥕🐇

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 PR标题清晰准确地反映了主要变更内容:组件库与各子库的解耦,涵盖了从monorepo中分离组件库的核心目标。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 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.

@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 56.33%. Comparing base (dc9bd71) to head (67be2a0).

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 60.33% <ø> (ø)
taro-web 53.12% <ø> (ø)

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 49 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
@yoyo837
Copy link
Contributor

yoyo837 commented Nov 11, 2025

@yoyo837 能不能帮忙发个alpha版

我没有release权限

This was referenced Nov 15, 2025
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 c5412ff and 67be2a0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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.json
  • packages/taro-components/package.json
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/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.json
  • packages/taro-components/package.json
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/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.json
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/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.json
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/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.json
  • packages/taro-platform-h5/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/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: ✓ 包导出结构符合发布要求

filesmainexports 的更新遵循现代 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} 包应提供替代导出。

需验证:

  1. 所有平台适配器和依赖者已更新为使用新的导出路径
  2. 构建和 CI 脚本已适配新的包结构
  3. 旧路径不存在遗留引用

25-25: 构建脚本简化是合理的,但需要验证 CI/CD 流程兼容性。

"prod" 脚本从 build:ci 改为 buildbuild 脚本从多步骤流程改为单一 stencil build 命令。这种简化符合解耦目标。

需确认:

  1. CI/CD 管道引用 pnpm run prodpnpm run build 的任何脚本都已适配此更改
  2. 原有 build:ci 中的任何特殊处理(如特定平台配置、特定构建标志等)未被遗漏
  3. 开发工作流(dev:components --watch 模式)与之前的 dev:library-* 脚本功能等价

Also applies to: 28-29

Comment on lines 27 to 31
"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",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

验证简化后的构建流程仍能生成所有必需的类型声明。

构建脚本已简化为单一的 stencil build 命令。根据之前的审查记录,类型生成曾是关键问题。需要确认:

  1. stencil.config.ts 中的 dist-custom-elements 目标是否已启用 generateTypeDeclarations: true,以自动生成 types/index.d.ts
  2. sync:types 脚本(第 31 行)是否需要添加到 prebuildprepare 命令中运行
  3. 简化后的 stencil build 是否确实生成以下所有产物:
    • dist/dist-custom-elements 输出
    • loader/ 产物
    • mini/ 产物
    • types/index.d.tsvue3.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 -20

Length of output: 304


🏁 Script executed:

#!/bin/bash
# Read the stencil config file
cat ./packages/taro-components/scripts/stencil/stencil.config.ts

Length 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 脚本未集成到构建流程中,导致类型声明缺少平台特定注解。

验证发现核心问题未解决:

  1. 类型生成机制确认:stencil build 通过配置的 dist 输出目标自动生成 types/index.d.ts ✓
  2. 平台注解更新缺失: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.

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