Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Sep 29, 2025

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能
    • 新增可选配置项,可在 Babel 处理链中插入自定义规则,提升构建可扩展性。
    • 默认不配置时行为保持不变,现有项目无需改动。
    • 为 JS/TS 构建提供更灵活的定制能力,同时保持兼容性。

@coderabbitai
Copy link

coderabbitai bot commented Sep 29, 2025

Walkthrough

在构建配置中,将针对 JS/TS 的 babel-loader 规则改为一组 oneOf 规则,并新增可选配置项 oneOfRulesForBabel 以在 babel-loader 之前插入额外规则。类型声明文件同步新增该配置项的定义,其余现有字段与行为保持不变。

Changes

Cohort / File(s) Change summary
类型声明更新
packages/build-next-bricks/index.d.ts
在接口 BuildNextBricksConfig 中新增可选属性 oneOfRulesForBabel?: RuleSetRule[];未修改或移除既有字段。
Webpack 构建规则调整
packages/build-next-bricks/src/build.js
将原先独立的 babel-loader 规则重构为 oneOf 组;支持通过 config.oneOfRulesForBabel 在 babel-loader 前插入额外规则;保留 rootMode: "upward" 等既有 babel-loader 配置,并在两处 JS/TS 规则中一致应用。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning PR 描述目前仅复刻了仓库提供的模板,且所有依赖检查和提交信息检查的复选框均未填写,缺少对依赖使用情况的确认、变更类型的标注、测试覆盖和手动验证等关键信息,远未满足模板要求。 请根据模板逐项完成依赖检查和提交信息检查的复选框,并在描述中补充本次 MR 的变更概要、是否涉及上游新特性、是否添加了单元测试及手动验证步骤等必要信息。
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed PR 标题“feat(): new option: oneOfRulesForBabel”直接点明了本次变更的核心——新增 oneOfRulesForBabel 配置选项,能够让阅读者一目了然地了解主要改动内容,因此符合“简明扼要、突出主要变更”的要求。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steve/v3-build

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new configuration option oneOfRulesForBabel that allows users to specify custom webpack rules that will be processed before the default Babel rule for TypeScript/JavaScript files.

  • Adds a new oneOfRulesForBabel configuration option to the webpack configuration
  • Wraps the existing Babel loader configuration in a oneOf array structure
  • Enables custom rule injection before the default Babel processing
Comments suppressed due to low confidence (1)

packages/build-next-bricks/src/build.js:1

  • The new oneOfRulesForBabel configuration option lacks documentation. Consider adding a comment explaining its purpose, expected format, and how it interacts with the default Babel rule to help maintainers understand this feature.
import path from "node:path";

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cypress
Copy link

cypress bot commented Sep 29, 2025

next-core    Run #11723

Run Properties:  status check passed Passed #11723  •  git commit 8690c76e16 ℹ️: Merge f2d3a30fb66d75743409cc2a2f9a202976e5c84e into 1bd10b55137c9b695f52e8fc73fe...
Project next-core
Branch Review steve/v3-build
Run status status check passed Passed #11723
Run duration 00m 25s
Commit git commit 8690c76e16 ℹ️: Merge f2d3a30fb66d75743409cc2a2f9a202976e5c84e into 1bd10b55137c9b695f52e8fc73fe...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@weareoutman weareoutman merged commit 987dfb6 into v3 Sep 29, 2025
8 of 9 checks passed
@weareoutman weareoutman deleted the steve/v3-build branch September 29, 2025 11:22
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 (3)
packages/build-next-bricks/index.d.ts (1)

91-94: 为 oneOfRulesForBabel 增补语义说明,避免误用

类型声明本身没问题,但建议用注释明确:

  • 这是插入到 JS/TS 处理链的 oneOf 组“前面进行匹配”的扩展点;
  • oneOf 语义为“命中后不再继续匹配后续规则”,若想“前置处理后仍使用 babel”,需在自定义规则的 use 链中自行包含 babel-loader。

可直接在类型上方添加 JSDoc:

   moduleRules?: RuleSetRule[];
+  /**
+   * 在 JS/TS oneOf 规则中优先匹配的自定义规则列表。
+   * 注意:该组为 oneOf,命中后不会再执行后续的 babel-loader。
+   * 如需“前置并继续 babel”,请在自定义 rule 的 use 链中显式包含 "babel-loader"。
+   */
   oneOfRulesForBabel?: RuleSetRule[];
packages/build-next-bricks/src/build.js (2)

361-371: 为外层 oneOf 增加 test 限定,缩小匹配范围并降低意外覆盖风险

目前外层规则无 test,会让所有资源进入该 oneOf 尝试匹配。建议仅限 JS/TS,以避免对图片/字体等后续规则造成潜在覆盖与无谓的正则测试。

-        {
-          oneOf: [
+        {
+          test: /\.[tj]sx?$/,
+          oneOf: [
             ...(config.oneOfRulesForBabel ?? []),
             {
-              test: /\.[tj]sx?$/,
               loader: "babel-loader",
               exclude: /node_modules|\.d\.ts$/,
               options: {
                 rootMode: "upward",
               },
             },
           ],
         },

说明:

  • 内层 Babel 子规则保留/去掉 test 均可;保留更直观,双层 test 不冲突。

361-371: 补充用法示例与最小验证用例

为减少误解,建议:

  • 在文档中给出两种示例:
    1. “替代 Babel”的 oneOf 自定义规则示例;
    2. “前置+继续 Babel”的自定义规则(use 链包含 babel-loader)示例。
  • 增加一个生成 webpack 配置的单测,断言:
    • 当 oneOfRulesForBabel 为空时,最终 oneOf 末项为 babel-loader;
    • 当提供匹配不到的规则时,仍落到 babel-loader;
    • 当提供匹配到的规则时,不再匹配 babel-loader(或示例中包含了 babel-loader)。

我可以帮忙起草示例与测试骨架。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 1bd10b5 and f2d3a30.

📒 Files selected for processing (2)
  • packages/build-next-bricks/index.d.ts (1 hunks)
  • packages/build-next-bricks/src/build.js (1 hunks)
⏰ 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 (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/build-next-bricks/src/build.js (1)

361-371: 确认 oneOf 规则是否按预期:自定义规则是替代还是在执行完毕后继续走 Babel?

  • 当前实现将 config.oneOfRulesForBabel 放在首位,若其中规则匹配 .ts/.tsx/.js,后续的 babel-loader 将被跳过——这是“替代”而非“前置+继续”。
  • 若目标是允许替代(如切换到 swc/ts-loader),无需调整;
  • 若目标是“前置处理后仍需执行 Babel”,需在文档中说明:在自定义规则中合并 babel-loader 或改用支持叠加的方案(如 enforce: 'pre' 或嵌套规则)。

建议在 README/CHANGELOG 中强调此行为并提供使用示例。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants