-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(harmony): 优化引入原生组件判断方法 #18537
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?
fix(harmony): 优化引入原生组件判断方法 #18537
Conversation
Walkthrough重构并调整了 taro-vite-runner 中两处路径解析与依赖显示路径计算逻辑;批量将大量包的 package.json 版本从 4.1.7 更新为 4.1.8-alpha.0;同时做了小幅类型与导出顺序调整、测试 mock 修改,并移除 CI 作业的超时配置。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant File as 当前文件 (rawId)
participant ImportArg as import 参数
participant Resolver as 解析器
participant Join as 条件性 join(仅相对)
participant resolveMain as resolveMainFilePath
rect rgba(100,149,237,0.06)
Note over File,Resolver: 旧流程(简化)
File->>Resolver: 将 importArg 与 rawId 解析为绝对路径
Resolver->>resolveMain: resolveMainFilePath(绝对路径)
resolveMain-->>File: 最终路径
end
rect rgba(60,179,113,0.06)
Note over File,Resolver: 新流程
File->>Resolver: 解析 importArg(保留原始 importPath 表示)
alt importPath 是相对路径
Resolver->>Join: path.join(path.dirname(rawId), importPath)
Join->>resolveMain: resolveMainFilePath(拼接后的路径)
else importPath 为绝对/根路径
Resolver->>resolveMain: resolveMainFilePath(规范化后的 importPath)
end
resolveMain-->>File: 最终路径
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 分钟
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/taro-vite-runner/src/common/babel-plugin-import-native-component.ts(1 hunks)packages/taro-vite-runner/src/harmony/page.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/taro-vite-runner/src/common/babel-plugin-import-native-component.ts (1)
packages/taro-helper/src/utils.ts (1)
resolveMainFilePath(244-276)
⏰ 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). (8)
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- 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 - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (1)
packages/taro-vite-runner/src/common/babel-plugin-import-native-component.ts (1)
22-26: 需要验证相对路径处理的完整性当前代码的
startsWith('.')判断存在潜在的不完整性。根据代码分析:
resolvePageImportPath的返回值可能包括:
- 相对路径:
./foo、../bar(会被解析)- 裸相对路径:
foo/bar(不会被解析)- 绝对路径或模块路径(按原样使用)
现有逻辑的潜在问题:
裸相对路径(如foo/bar)不以.开头,会跳过path.resolve(),直接传给resolveMainFilePath()。这可能导致路径解析不正确。对比发现:
在mini.ts的collectNativeComponents方法中(第109行),总是直接对原始路径调用path.resolve(),而不是有条件地调用,这表示处理模式可能不一致。建议验证
compiler.resolvePageImportPath()在实际运行中是否会返回裸相对路径,以确保不会出现路径解析遗漏的情况。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18537 +/- ##
=======================================
Coverage 55.97% 55.97%
=======================================
Files 416 416
Lines 21560 21560
Branches 5289 5259 -30
=======================================
Hits 12069 12069
+ Misses 8002 7913 -89
- Partials 1489 1578 +89
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
2ad449a to
74f2997
Compare
74f2997 to
022f482
Compare
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 selected for processing (85)
.github/workflows/nodejs.yml(0 hunks)crates/native_binding/package.json(1 hunks)npm/darwin-arm64/package.json(1 hunks)npm/darwin-x64/package.json(1 hunks)npm/linux-x64-gnu/package.json(1 hunks)npm/linux-x64-musl/package.json(1 hunks)npm/win32-x64-msvc/package.json(1 hunks)package.json(2 hunks)packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json(1 hunks)packages/babel-plugin-transform-solid-jsx/package.json(1 hunks)packages/babel-plugin-transform-taroapi/package.json(1 hunks)packages/babel-plugin-transform-taroapi/tests/__mocks__/h5-definition.json(1 hunks)packages/babel-preset-taro/package.json(1 hunks)packages/create-app/package.json(1 hunks)packages/css-to-react-native/package.json(1 hunks)packages/eslint-config-taro/package.json(1 hunks)packages/eslint-plugin-taro/package.json(1 hunks)packages/jest-helper/package.json(1 hunks)packages/postcss-html-transform/package.json(1 hunks)packages/postcss-plugin-constparse/package.json(1 hunks)packages/postcss-pxtransform/package.json(1 hunks)packages/postcss-unit-transform/package.json(1 hunks)packages/rollup-plugin-copy/package.json(1 hunks)packages/shared/package.json(1 hunks)packages/stylelint-config-taro-rn/package.json(1 hunks)packages/stylelint-taro-rn/package.json(1 hunks)packages/stylelint-taro/package.json(1 hunks)packages/taro-api/package.json(1 hunks)packages/taro-cli-convertor/package.json(1 hunks)packages/taro-cli/package.json(1 hunks)packages/taro-components-advanced/package.json(1 hunks)packages/taro-components-library-react/package.json(1 hunks)packages/taro-components-library-react/src/react-component-lib/utils/index.tsx(2 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-rn/package.json(1 hunks)packages/taro-components/package.json(1 hunks)packages/taro-extend/package.json(1 hunks)packages/taro-framework-react/package.json(1 hunks)packages/taro-framework-solid/package.json(1 hunks)packages/taro-framework-vue3/package.json(1 hunks)packages/taro-h5/package.json(1 hunks)packages/taro-helper/package.json(1 hunks)packages/taro-loader/package.json(1 hunks)packages/taro-platform-alipay/package.json(1 hunks)packages/taro-platform-ascf/package.json(1 hunks)packages/taro-platform-h5/package.json(1 hunks)packages/taro-platform-harmony-cpp/package.json(1 hunks)packages/taro-platform-harmony-hybrid/package.json(1 hunks)packages/taro-platform-harmony/package.json(1 hunks)packages/taro-platform-jd/package.json(1 hunks)packages/taro-platform-qq/package.json(1 hunks)packages/taro-platform-swan/package.json(1 hunks)packages/taro-platform-tt/package.json(1 hunks)packages/taro-platform-weapp/package.json(1 hunks)packages/taro-plugin-generator/package.json(1 hunks)packages/taro-plugin-html/package.json(1 hunks)packages/taro-plugin-http/package.json(1 hunks)packages/taro-plugin-inject/package.json(1 hunks)packages/taro-plugin-mini-ci/package.json(1 hunks)packages/taro-plugin-react-devtools/package.json(1 hunks)packages/taro-plugin-vue-devtools/package.json(1 hunks)packages/taro-react/package.json(1 hunks)packages/taro-rn-runner/package.json(1 hunks)packages/taro-rn-style-transformer/package.json(1 hunks)packages/taro-rn-supporter/package.json(1 hunks)packages/taro-rn-transformer/package.json(1 hunks)packages/taro-rn/package.json(1 hunks)packages/taro-rn/src/lib/index.ts(1 hunks)packages/taro-router-rn/package.json(1 hunks)packages/taro-router/package.json(1 hunks)packages/taro-runner-utils/package.json(1 hunks)packages/taro-runtime-rn/package.json(1 hunks)packages/taro-runtime/package.json(1 hunks)packages/taro-service/package.json(1 hunks)packages/taro-transformer-wx/package.json(1 hunks)packages/taro-vite-runner/package.json(1 hunks)packages/taro-vite-runner/src/common/babel-plugin-import-native-component.ts(1 hunks)packages/taro-vite-runner/src/harmony/page.ts(2 hunks)packages/taro-webpack5-prebundle/package.json(1 hunks)packages/taro-webpack5-runner/package.json(1 hunks)packages/taro-with-weapp/package.json(1 hunks)packages/taro/package.json(1 hunks)packages/taroize/package.json(1 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/nodejs.yml
✅ Files skipped from review due to trivial changes (11)
- packages/taro-framework-solid/package.json
- packages/taro-plugin-vue-devtools/package.json
- packages/taro-platform-weapp/package.json
- npm/win32-x64-msvc/package.json
- packages/taro-cli-convertor/package.json
- packages/taro-platform-jd/package.json
- packages/stylelint-taro-rn/package.json
- packages/taro-plugin-inject/package.json
- packages/taro-vite-runner/package.json
- packages/postcss-unit-transform/package.json
- packages/taro-platform-tt/package.json
🚧 Files skipped from review as they are similar to previous changes (55)
- packages/create-app/package.json
- packages/taro/package.json
- packages/taro-framework-react/package.json
- packages/eslint-plugin-taro/package.json
- packages/taro-components-advanced/package.json
- packages/postcss-plugin-constparse/package.json
- packages/taro-components-library-react/package.json
- packages/taro-platform-harmony/package.json
- packages/taro-router-rn/package.json
- packages/postcss-pxtransform/package.json
- packages/taro-rn-supporter/package.json
- packages/taro-components-library-vue3/package.json
- packages/taro-cli/package.json
- packages/taro-with-weapp/package.json
- packages/taro-plugin-html/package.json
- packages/taro-runtime/package.json
- packages/taro-platform-ascf/package.json
- npm/darwin-x64/package.json
- npm/linux-x64-musl/package.json
- packages/taro-framework-vue3/package.json
- packages/babel-plugin-transform-taroapi/package.json
- packages/taro-components-rn/package.json
- packages/taro-platform-h5/package.json
- npm/darwin-arm64/package.json
- packages/taro-helper/package.json
- packages/taro-components-react/package.json
- packages/taro-components-library-solid/package.json
- packages/jest-helper/package.json
- packages/taro-rn-runner/package.json
- packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json
- packages/taro-runtime-rn/package.json
- packages/taro-vite-runner/src/harmony/page.ts
- package.json
- packages/taro-react/package.json
- packages/rollup-plugin-copy/package.json
- crates/native_binding/package.json
- packages/eslint-config-taro/package.json
- packages/babel-plugin-transform-taroapi/tests/mocks/h5-definition.json
- packages/taro-plugin-generator/package.json
- packages/taro-platform-qq/package.json
- packages/postcss-html-transform/package.json
- packages/taro-webpack5-runner/package.json
- packages/taro-plugin-http/package.json
- packages/taro-vite-runner/src/common/babel-plugin-import-native-component.ts
- packages/taroize/package.json
- packages/taro-loader/package.json
- packages/taro-platform-swan/package.json
- packages/taro-plugin-react-devtools/package.json
- packages/taro-platform-alipay/package.json
- packages/shared/package.json
- packages/taro-platform-harmony-hybrid/package.json
- packages/stylelint-taro/package.json
- packages/taro-extend/package.json
- packages/taro-rn-transformer/package.json
- packages/taro-runner-utils/package.json
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: ianzone
Repo: NervJS/taro PR: 18146
File: packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json:12-14
Timestamp: 2025-08-08T02:32:58.265Z
Learning: 在 Taro 项目的 pnpm 工作区中,Vitest 相关依赖(vitest 和 vitest/coverage-istanbul)被管理在根目录的 package.json 中,而不是各个子包的 devDependencies 中。这是 monorepo 中依赖提升的标准做法。
Learnt from: ianzone
Repo: NervJS/taro PR: 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 文件。
📚 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-rn/package.jsonpackages/taro-h5/package.jsonpackages/taro-transformer-wx/package.jsonpackages/taro-rn-style-transformer/package.jsonpackages/taro-rn/src/lib/index.tspackages/taro-components/package.jsonpackages/taro-api/package.jsonpackages/babel-preset-taro/package.jsonpackages/taro-platform-harmony-cpp/package.jsonpackages/taro-webpack5-prebundle/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-rn/package.jsonpackages/taro-h5/package.jsonpackages/taro-rn/src/lib/index.tspackages/taro-components/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/package.jsonpackages/taro-platform-harmony-cpp/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). (9)
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- 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
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (20)
packages/taro-h5/package.json (1)
3-3: 版本号更新一致且正确。版本号从 4.1.7 更新至 4.1.8-alpha.0,符合 PR 中的协调版本更新计划。没有其他依赖项或配置的改动。
packages/stylelint-config-taro-rn/package.json (1)
3-3: 版本号更新至预发行版本。版本已从
4.1.7更新至4.1.8-alpha.0。请确认此次版本升级与 PR 目标相关,并验证此包的所有依赖者也已相应更新(如适用)。根据 AI 摘要,本次更新涉及多个包的批量版本升级,建议确认版本号变更与预发行标签的一致性。
packages/taro-api/package.json (1)
3-3: 版本更新一致且合理。版本号从 4.1.7 更新至 4.1.8-alpha.0 与 PR 中其他包的广泛版本更新一致,符合 monorepo 中的协调版本管理实践。该预发布版本标签适当标识了这一 alpha 阶段的更新。
packages/taro-webpack5-prebundle/package.json (1)
3-3: 版本更新与 PR 目标不一致。该文件的版本从 4.1.7 更新至 4.1.8-alpha.0,但根据 PR 目标描述,此提交的目的是"优化引入原生组件判断方法"。建议验证这个版本号更改是否为有意的批量更新(跨多个包),还是意外包含在此 PR 中的。
若这是跨包的协调式版本发布,建议在 PR 描述中明确说明版本更新的原因和范围。
packages/css-to-react-native/package.json (1)
4-4: 版本号更新与 PR 目标关联性需要验证第 4 行的版本号从
4.1.7升级为4.1.8-alpha.0。根据 PR 摘要,此次变更涉及跨仓库的大范围版本更新。建议确认:
- 该包在鸿蒙平台的原生组件判断优化中是否涉及功能变更(目前仅观察到版本号变更)
- 该预发布版本号是否与同步更新的其他包版本保持一致
packages/taro-service/package.json (1)
3-3: 版本更新与 PR 目标不一致。PR 目标声明此 PR 是为了"优化引入原生组件判断方法"(代码层面的修复),但该文件中仅包含版本号从 4.1.7 更新到 4.1.8-alpha.0 的变更,没有任何实际的代码修改。虽然 AI 摘要表明这是整个仓库中多个包的批量版本更新,但需要确认:
- 这个版本更新是否应该属于此 PR,还是应该在单独的发布 PR 中进行
- 如果此 PR 的主要目的是代码优化(harmony 原生组件判断),版本号的更新应该在 changelog 或提交信息中明确说明
建议:请确保 PR 描述、commit messages 和实际变更保持一致,或考虑将版本更新与代码优化变更分离为两个独立的 PR。
packages/taro-components/package.json (1)
3-3: 版本号更新为预发布版本。package.json 中的版本号从 4.1.7 更新至 4.1.8-alpha.0。根据 AI 总结,这似乎是整个 monorepo 中多个包的协调版本更新。
需要确认:
- 此版本号更新是否与 PR 的主要目标(优化原生组件判断方法)一致?
- 其他相关包(如 @tarojs/runtime、@tarojs/shared 等)的 workspace 依赖是否也已相应更新?
packages/taro-plugin-mini-ci/package.json (1)
3-3: 版本号更新一致性需要确认。文件中的版本号已从
4.1.7更新至4.1.8-alpha.0。根据 AI 摘要,此次更新是跨多个包的协调版本升级。请确认所有相关包的版本号均已一致更新。此外,当前 PR 的标题和目标描述涉及 Harmony 平台原生组件判断逻辑的优化,但此文件仅包含版本号更改。建议验证是否存在其他包含实际逻辑更改的文件未在审查范围内,或确认此版本号更新是否为独立的发布周期变更。
packages/taro-platform-harmony-cpp/package.json (1)
3-3: 版本更新与 PR 目标不符 - 仅显示版本号变更此文件仅包含版本号从 4.1.7 更新至 4.1.8-alpha.0 的变更,与 PR 标题中提及的"优化引入原生组件判断方法"的逻辑优化不符。建议确认以下事项:
- 实际的逻辑优化代码是否在其他文件中进行
- 此版本号更新是否与整个 PR 中的其他包版本更新保持一致(根据 AI 摘要提示的批量版本更新)
packages/taro-rn/package.json (1)
3-3: 版本号更新一致,遵循语义化版本规范。版本从 4.1.7 更新为 4.1.8-alpha.0,符合语义化版本规范中的预发行版本格式。此次更新与 AI 总结中描述的跨包批量版本更新一致。
packages/taro-router/package.json (2)
3-3: 版本号更新一致,遵循语义化版本规范。版本从 4.1.7 更新为 4.1.8-alpha.0,符合语义化版本规范中的预发行版本格式。此次更新与 AI 总结中描述的跨包批量版本更新一致。
1-55: 请验证 PR 范围与提供文件的对应关系。PR 标题和描述指出本次修复针对"鸿蒙(Harmony)平台优化原生组件判断方法",但提供的审查文件(taro-rn 和 taro-router)为通用 React Native 和路由包,与鸿蒙平台特定的变更不直接对应。建议确认:
- 是否为该 PR 配置的完整文件列表,或是否存在相关鸿蒙平台特定的源代码变更文件(例如 taro-vite-runner 中提到的路径解析优化)
- 版本号更新是否为该 PR 的附带变更
packages/taro-transformer-wx/package.json (1)
3-3: 版本号更新已确认与整个 monorepo 保持一致。验证结果确认:79 个 package.json 文件中的版本已统一更新为 4.1.8-alpha.0,无遗漏或不一致情况(原有 4.1.7 版本的包数为 0)。此变更符合预期的统一版本更新计划。
npm/linux-x64-gnu/package.json (1)
4-4: 版本号更新为预发布版本,符合本 PR 的版本管理策略版本从 4.1.7 更新至 4.1.8-alpha.0,采用标准的 semver 预发布版本格式,与整个单体仓库的版本更新保持一致。
packages/babel-preset-taro/package.json (1)
3-3: 版本号与单体仓库预发布策略保持一致版本从 4.1.7 更新至 4.1.8-alpha.0。作为核心的 Babel 预设包,该版本更新与其他依赖包保持同步,符合单体仓库的版本管理要求。
packages/babel-plugin-transform-solid-jsx/package.json (2)
4-4: 版本号更新保持一致性版本从 4.1.7 更新至 4.1.8-alpha.0,与单体仓库内其他包保持同步。
1-40: 注意:PR 范围与提供的文件存在偏差PR 标题和目标描述聚焦于"harmony 平台的原生组件判断方法优化",但本次审查提供的三个文件均为通用的版本号更新(package.json metadata)。根据 AI 生成的摘要,PR 中还包含 taro-vite-runner 中的路径解析逻辑重构和 harmony/page.ts 中的路径标准化修改等功能性改动,但这些文件未在本审查中提供。
请确认:
- 本审查是否仅涵盖版本号更新部分?
- Harmony 特性相关的实质性代码改动是否已在其他审查中提交?
packages/taro-components-library-react/src/react-component-lib/utils/index.tsx (2)
5-5: 导入必要的类型工具。添加
PropsWithoutRef导入是合理的,用于支持下方的类型改进。
35-45: 类型签名改进正确且安全。验证了
createForwardRef在整个代码库中的使用情况:
- 主要使用点在
packages/taro-components-library-react/src/react-component-lib/createComponent.tsx第 121 行,调用时正确使用了泛型:createForwardRef<PropType, ElementType>(ReactComponent, displayName)- 所有 props 转发都遵循正确的模式:
{...props}+ 单独的forwardedRef={ref}参数- 没有发现代码错误地在 props 中传递
ref属性的情况
PropsWithoutRef包装器确保类型安全,防止ref被包含在 props 对象中,这与React.forwardRef的类型签名要求一致。packages/taro-rn-style-transformer/package.json (1)
3-3: 版本号更新正常。这是 monorepo 范围内的常规预发布版本更新,从 4.1.7 升级到 4.1.8-alpha.0,符合预期。
| // 由 getLibList.js 脚本生成, 不要进行手动修改, 请不要手动修改 | ||
| export * from './ENV_TYPE' |
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
请确认自动生成脚本是否已同步更新。
文件头部注释明确标注此文件由 getLibList.js 脚本自动生成,不应手动修改。但本次 PR 将 ENV_TYPE 的导出从字母顺序位置移动到了顶部,这打破了原有的字母排序规则。
请确认:
- 是否已同步更新
getLibList.js脚本以反映此更改? - 将
ENV_TYPE移到顶部的具体原因是什么(例如:避免循环依赖、确保初始化顺序等)? - 此更改与 PR 目标"优化引入原生组件判断方法"的关联是什么?
如果这是必要的手动调整,建议在注释中说明原因,避免未来脚本重新生成时被覆盖。
运行以下脚本验证 getLibList.js 生成器脚本的内容:
🏁 Script executed:
#!/bin/bash
# 查找并检查 getLibList.js 脚本
fd -t f 'getLibList.js' packages/taro-rn
# 查看脚本内容以确认是否包含 ENV_TYPE 特殊处理逻辑
rg -A 5 -B 5 "ENV_TYPE" packages/taro-rn --type=jsLength of output: 37
🏁 Script executed:
#!/bin/bash
# View the getLibList.js script to understand generation logic
cat packages/taro-rn/script/getLibList.js
# Also view the generated index.ts file to confirm current state
echo "=== Current state of index.ts ==="
head -20 packages/taro-rn/src/lib/index.tsLength of output: 1710
确认需要更新生成脚本或添加文档说明。
getLibList.js 脚本经检查不包含任何特殊逻辑来处理 ENV_TYPE。脚本的生成逻辑非常简单:仅按目录顺序(通常为字母顺序)读取并生成导出语句。
现状分析:
- 脚本中
ENV_TYPE零特殊处理逻辑 - 当前
index.ts中ENV_TYPE被手动放在顶部,打破了字母序(应该在 "e" 之后,但却是第一个) - 这是对自动生成文件的直接手动修改,违反了文件头的声明
需要采取以下措施之一:
- 更新
getLibList.js脚本,添加ENV_TYPE的特殊排序逻辑(若有特殊原因需要其优先) - 在文件头注释中说明原因,明确这是必要的手动调整(例如避免循环依赖),防止脚本重新生成时被覆盖
🤖 Prompt for AI Agents
In packages/taro-rn/src/lib/index.ts around lines 1 to 2, the generated file was
manually modified to place ENV_TYPE at the top which breaks the generator's
alphabetical ordering; either update the getLibList.js generator to apply
special ordering for ENV_TYPE (so it is emitted first reliably) or revert the
manual change and add a clear header comment above the export explaining why
ENV_TYPE must be ordered first (e.g., to avoid circular dependency) so future
regenerations or reviewers know this is an intentional exception; implement one
of these two fixes and ensure the generator and repository reflect the chosen
approach (update script tests/docs or add the explanatory comment and commit).
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
发布说明
优化改进
重构
测试
杂项