Skip to content

fix(taro-components-advanced): 修复 Taro.xxx 调用报错 #17755

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

Merged
merged 2 commits into from
Jun 3, 2025

Conversation

Single-Dancer
Copy link
Collaborator

@Single-Dancer Single-Dancer commented May 22, 2025

这个 PR 做了什么? (简要描述所做更改)
修复 waterflow 组件里 Taro.xxx 相关调用报错,原因是 babel-plugin-transform-taroapi 对于 Taro.xxx 转换为 import {xxx} from '@tarojs/taro' 不会处理npm包

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • [*] 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • [*] Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Summary by CodeRabbit

  • 优化
    • 精简依赖,仅按需引入 Taro 的相关方法,减少包体积并提升性能。
    • 组件功能和使用方式保持不变,无用户操作变更。
  • 版本更新
    • 多个包版本升级至 4.1.2-alpha.0,提升整体稳定性和兼容性。

Copy link

coderabbitai bot commented May 22, 2025

## Walkthrough

本次更改将对 Taro 相关 API 的导入方式进行了优化,由原本的整体命名空间引入改为只按需引入所需的函数。涉及的组件包括 water-flow 的 root、utils 和主文件,代码逻辑及功能未发生变化,仅调整了导入和调用方式。此外,多个包的 package.json 文件版本号统一从 4.1.1 更新为 4.1.2-alpha.0,未改动其他内容。

## Changes

| 文件/路径                                                                                          | 变更摘要                                                         |
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| packages/taro-components-advanced/src/components/water-flow/root.ts<br>packages/taro-components-advanced/src/components/water-flow/water-flow.ts |`Taro` 整体导入改为只按需导入 `nextTick`,并相应修改了调用方式。|
| packages/taro-components-advanced/src/components/water-flow/utils.ts                              |`Taro` 整体导入改为只按需导入 `getEnv``getSystemInfoSync`,并相应修改了类型和调用方式。|
| 多个 package.json 文件(如 crates/native_binding/package.json、npm/darwin-arm64/package.json、packages/taro-components-advanced/package.json 等) | 版本号统一从 `4.1.1` 更新为 `4.1.2-alpha.0`,未改动其他内容。    |

## Suggested reviewers

- tutuxxx

## Poem

> 小兔敲键盘,代码轻轻换,  
> Taro 不再全员到场,  
> 按需引入更清爽,  
> 逻辑未变心欢畅,  
> 优雅如风,跃进一行,  
> 组件依旧稳如磐。  
> 🐇✨

📜 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 ab8e505 and 1c264d9.

📒 Files selected for processing (79)
  • 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 (1 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-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/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-advanced/src/components/water-flow/root.ts (2 hunks)
  • packages/taro-components-advanced/src/components/water-flow/utils.ts (2 hunks)
  • packages/taro-components-advanced/src/components/water-flow/water-flow.ts (2 hunks)
  • 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-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-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-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-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-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 skipped from review due to trivial changes (33)
  • packages/taro-platform-weapp/package.json
  • packages/css-to-react-native/package.json
  • packages/taro-router-rn/package.json
  • packages/taro-rn-transformer/package.json
  • packages/taro-cli/package.json
  • packages/postcss-unit-transform/package.json
  • packages/postcss-html-transform/package.json
  • packages/taro-vite-runner/package.json
  • packages/taro-platform-harmony-hybrid/package.json
  • packages/taro-h5/package.json
  • packages/taro-components-react/package.json
  • packages/taro-components-library-react/package.json
  • packages/taro-webpack5-prebundle/package.json
  • packages/taro-platform-swan/package.json
  • packages/taro-transformer-wx/package.json
  • packages/taro-rn-runner/package.json
  • packages/taro-components-library-solid/package.json
  • packages/babel-plugin-transform-solid-jsx/package.json
  • packages/taro-components-library-vue3/package.json
  • npm/win32-x64-msvc/package.json
  • packages/stylelint-taro-rn/package.json
  • npm/linux-x64-gnu/package.json
  • packages/rollup-plugin-copy/package.json
  • packages/taro-framework-vue3/package.json
  • packages/taro-components-advanced/src/components/water-flow/root.ts
  • packages/taro-platform-alipay/package.json
  • packages/taro-cli-convertor/package.json
  • packages/taro-platform-harmony/package.json
  • packages/taro-framework-solid/package.json
  • packages/taro-runner-utils/package.json
  • packages/taro-components-advanced/package.json
  • packages/taro-rn-supporter/package.json
  • package.json
🚧 Files skipped from review as they are similar to previous changes (46)
  • packages/postcss-pxtransform/package.json
  • packages/taro-platform-tt/package.json
  • packages/taro-plugin-react-devtools/package.json
  • packages/taro-platform-harmony-cpp/package.json
  • packages/babel-preset-taro/package.json
  • packages/create-app/package.json
  • packages/taro-components/package.json
  • packages/taro-components-rn/package.json
  • packages/taro-api/package.json
  • npm/darwin-arm64/package.json
  • packages/taro-plugin-html/package.json
  • npm/linux-x64-musl/package.json
  • packages/eslint-config-taro/package.json
  • packages/shared/package.json
  • packages/taro-platform-h5/package.json
  • packages/babel-plugin-transform-taroapi/package.json
  • packages/taro-webpack5-runner/package.json
  • packages/taro-runtime-rn/package.json
  • packages/taro-loader/package.json
  • packages/taro-platform-qq/package.json
  • packages/taro-plugin-vue-devtools/package.json
  • packages/stylelint-taro/package.json
  • packages/stylelint-config-taro-rn/package.json
  • packages/taro-helper/package.json
  • packages/taro-framework-react/package.json
  • packages/taro-plugin-inject/package.json
  • packages/taro-rn/package.json
  • packages/taro-runtime/package.json
  • packages/taro-plugin-mini-ci/package.json
  • packages/jest-helper/package.json
  • packages/taro-platform-jd/package.json
  • packages/taroize/package.json
  • packages/taro-with-weapp/package.json
  • packages/taro-components-advanced/src/components/water-flow/water-flow.ts
  • packages/taro-extend/package.json
  • packages/taro-service/package.json
  • packages/taro-rn-style-transformer/package.json
  • packages/taro-react/package.json
  • npm/darwin-x64/package.json
  • packages/postcss-plugin-constparse/package.json
  • packages/taro-plugin-http/package.json
  • packages/taro/package.json
  • packages/taro-router/package.json
  • crates/native_binding/package.json
  • packages/taro-components-advanced/src/components/water-flow/utils.ts
  • packages/babel-plugin-transform-react-jsx-to-rn-stylesheet/package.json
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • 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 - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Single-Dancer Single-Dancer added this to the 4.0.14 milestone May 22, 2025
@coderabbitai coderabbitai bot requested a review from tutuxxx May 22, 2025 08:24
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.37%. Comparing base (0eddaa8) to head (1c264d9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17755   +/-   ##
=======================================
  Coverage   59.37%   59.37%           
=======================================
  Files         387      387           
  Lines       23417    23417           
  Branches     5129     5160   +31     
=======================================
  Hits        13903    13903           
+ Misses       8048     8017   -31     
- Partials     1466     1497   +31     
Flag Coverage Δ
taro-cli 72.37% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

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

see 9 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.

@Single-Dancer Single-Dancer merged commit 3617471 into main Jun 3, 2025
43 checks passed
@Single-Dancer Single-Dancer deleted the fix/waterflow branch June 3, 2025 03:25
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