Skip to content

fix: 修复编译单个组件在小程序下路径异常的问题#3215

Merged
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:chore-taro-mp
May 1, 2025
Merged

fix: 修复编译单个组件在小程序下路径异常的问题#3215
irisSong merged 1 commit intojdf2e:feat_v3.xfrom
xiaoyatong:chore-taro-mp

Conversation

@xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented May 1, 2025

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • Bug Fixes
    • 修复导航配置中包含空页面数组的问题,现在只保留至少包含一个页面的导航项。

@coderabbitai
Copy link

coderabbitai bot commented May 1, 2025

Walkthrough

本次更改将 configRef 变量由常量(const)改为可变变量(let),并在填充完包含导航根及其页面的配置对象后,新增了过滤步骤,移除所有 pages 数组为空的条目。这样可以确保最终配置中只包含至少有一个页面的导航项。其余关于构建 pages 数组和推送配置对象的逻辑未发生变化。

Changes

文件路径 变更摘要
scripts/harmony/update-taro-entry.js configRefconst 改为 let,并新增过滤,移除 pages 为空的配置项。

Suggested reviewers

  • oasis-cloud

Poem

🐇
代码小兔跳一跳,
配置过滤真巧妙。
空页面说再见,
导航清爽又可靠。
变量灵活转一转,
Harmony世界更美好!

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

@github-actions github-actions bot added 3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) labels May 1, 2025
@codecov
Copy link

codecov bot commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.54%. Comparing base (bd9f30b) to head (c334ebc).
Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3215   +/-   ##
==========================================
  Coverage      86.53%   86.54%           
==========================================
  Files            289      289           
  Lines          18739    18739           
  Branches        2821     2822    +1     
==========================================
+ Hits           16216    16217    +1     
+ Misses          2518     2517    -1     
  Partials           5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

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

🧹 Nitpick comments (2)
scripts/harmony/update-taro-entry.js (2)

1-84: 建议:增加错误处理和日志

当前实现在过滤空页面后可能会导致 configRef 为空数组的情况,建议添加一些错误处理和日志记录,以便在没有任何匹配组件时提供更好的反馈。

// 如果 pages 数据为空,则删除该项
configRef = configRef.filter((item) => item.pages.length !== 0)

+ // 如果过滤后没有任何配置项,输出警告信息
+ if (configRef.length === 0) {
+   console.warn('警告: 过滤后没有任何匹配的组件,请检查输入参数')
+ }

res(configRef)

1-84: 建议:添加单元测试

为了确保此修复在各种情况下都能正常工作,建议添加单元测试来覆盖以下场景:

  1. 标准使用场景(不使用参数)
  2. 使用 C 参数指定单个组件
  3. 使用 C 参数指定多个组件
  4. 使用 G 参数指定导航部分
  5. 使用参数但没有匹配到任何组件的情况

这将有助于防止未来的回归问题。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd9f30b and c334ebc.

📒 Files selected for processing (1)
  • scripts/harmony/update-taro-entry.js (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/harmony/update-taro-entry.js (3)
scripts/taro/generate-taro-route.js (2)
  • configRef (9-9)
  • config (2-2)
scripts/taro/generate-taro-pages.js (1)
  • config (4-4)
scripts/create-component-mode.js (1)
  • config (5-5)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (3)
scripts/harmony/update-taro-entry.js (3)

24-24: 将常量改为变量以支持后续的过滤操作

configRefconst 修改为 let 是必要的,因为在后面的代码中需要重新赋值该变量,特别是在第54行中的过滤操作。这是一个良好的变更,为下面的新增逻辑奠定了基础。


32-33: 代码缩进格式调整

缩进格式的调整有助于提高代码的可读性,使条件语句的层次结构更加清晰。


53-54: 关键修复:过滤掉空页面数组的配置项

这是本次PR的核心修复。通过过滤掉 pages 数组为空的配置项,解决了在编译单个组件时可能导致的路径异常问题。当使用环境变量 C 参数指定单个组件进行编译时,有些导航部分可能不包含任何页面,这可能导致在小程序构建过程中出现路径异常。这个修复确保了只有包含至少一个页面的导航项才会被包含在最终的配置中。

这是一个重要且必要的修复,能有效解决PR描述中提到的"编译单个组件在小程序下路径异常的问题"。

@xiaoyatong
Copy link
Collaborator Author

image

@irisSong irisSong merged commit e84f671 into jdf2e:feat_v3.x May 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants