Skip to content

Conversation

@panyu97py
Copy link
Contributor

@panyu97py panyu97py commented Dec 18, 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

  • Bug 修复
    • 改进本地 PostCSS 插件的路径解析:现在支持绝对路径和相对路径并存。绝对路径将保持不变,只有非绝对(相对)路径会基于应用根路径解析,从而减少插件加载路径错误并提升配置灵活性与稳定性。

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

在三个 PostCSS 配置文件中优化了本地插件路径解析逻辑。修改后,仅当插件名称为相对路径时才与应用路径进行拼接;若插件名已为绝对路径,则保持原值,避免重复拼接或错误解析。

Changes

Cohort / 文件(s) 改动摘要
PostCSS 本地插件路径解析优化
packages/taro-webpack5-runner/src/postcss/postcss.h5.ts, packages/taro-webpack5-runner/src/postcss/postcss.harmony.ts, packages/taro-webpack5-runner/src/postcss/postcss.mini.ts
调整 getPostcssPlugins 中本地插件路径解析:增加绝对路径检查(path.isAbsolute),仅在 pluginName 为相对路径时才执行 path.join(appPath, pluginName);绝对路径保持不变。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

T-harmony

Suggested reviewers

  • luckyadam
  • yoyo837
  • tutuxxx

Poem

🐰 三处文件悄改忙,路径判断更从容,
绝对路径不再拼,避免重复与错误,
相对插件照旧联,加载稳稳又轻松,
PostCSS 路径清晰了,编译步骤更顺通,
小兔一跳庆更新,代码整洁心欢欣。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确总结了主要变更:修复PostCSS支持绝对路径插件的问题,与所有三个文件的代码变更直接相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd24a67 and 465fbca.

📒 Files selected for processing (3)
  • packages/taro-webpack5-runner/src/postcss/postcss.h5.ts
  • packages/taro-webpack5-runner/src/postcss/postcss.harmony.ts
  • packages/taro-webpack5-runner/src/postcss/postcss.mini.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/taro-webpack5-runner/src/postcss/postcss.harmony.ts
  • packages/taro-webpack5-runner/src/postcss/postcss.mini.ts
🧰 Additional context used
🧠 Learnings (1)
📚 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-webpack5-runner/src/postcss/postcss.h5.ts
🧬 Code graph analysis (1)
packages/taro-webpack5-runner/src/postcss/postcss.h5.ts (2)
packages/babel-preset-taro/index.js (1)
  • path (1-1)
packages/taro-platform-harmony-cpp/scripts/constant.ts (1)
  • appPath (13-13)
⏰ 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 - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (1)
packages/taro-webpack5-runner/src/postcss/postcss.h5.ts (1)

90-93: 逻辑正确,修复了绝对路径插件的支持问题。

此修改正确实现了对绝对路径插件的支持:

  • 使用 path.isAbsolute() 检查插件名是否为绝对路径
  • 绝对路径直接使用,避免错误拼接
  • 相对路径保持原有行为(与 appPath 拼接)

这解决了自定义 Taro 插件通过 modifyRunnerOpts API 传入绝对路径 PostCSS 插件时的路径解析问题。同时已验证 postcss.harmony.ts 和 postcss.mini.ts 中的修改保持一致。

建议为此修复添加单元测试,覆盖以下场景:

  1. 使用绝对路径的本地插件
  2. 使用相对路径的本地插件
  3. npm 包插件(确保不受影响)

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.

@panyu97py
Copy link
Contributor Author

panyu97py commented Dec 18, 2025

自定义 taro 插件通过 modifyRunnerOpts api 修改 postcss 配置时 无法使用 自定义 taro 插件依赖的 postcss plugin

具体 case 参考 仓库代码

@panyu97py
Copy link
Contributor Author

panyu97py commented Jan 5, 2026

@Single-Dancer 有可能把taro 支持分包异步加载放到Taro文档中推荐吗?能解决微信小程序主包体积不够的问题。
和Taro文档中动态import功能类似,但使用的是微信的api没有合规风险

@Single-Dancer Single-Dancer force-pushed the fixPostcssPluginSupportAbsolutePath branch from cd24a67 to 465fbca Compare January 8, 2026 08:32
@Single-Dancer
Copy link
Collaborator

@Single-Dancer 有可能把taro 支持分包异步加载放到Taro文档中推荐吗?能解决微信小程序主包体积不够的问题。 和Taro文档中动态import功能类似,但使用的是微信的api没有合规风险

@tutuxxx 帮忙看看

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.32%. Comparing base (9a985ce) to head (465fbca).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #18683    +/-   ##
========================================
  Coverage   56.32%   56.32%            
========================================
  Files         447      447            
  Lines       23345    23345            
  Branches     5745     5796    +51     
========================================
  Hits        13149    13149            
- Misses       8363     8492   +129     
+ Partials     1833     1704   -129     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 60.27% <ø> (ø)
taro-web 53.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 39 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 60be41b into NervJS:main Jan 8, 2026
24 checks passed
@panyu97py
Copy link
Contributor Author

@Single-Dancer 有可能把taro 支持分包异步加载放到Taro文档中推荐吗?能解决微信小程序主包体积不够的问题。 和Taro文档中动态import功能类似,但使用的是微信的api没有合规风险

@tutuxxx 帮忙看看

@tutuxxx 辛苦看看呢

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