Skip to content

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Nov 10, 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

  • 新功能
    • 在 brick 生成流程中新增对 JSX 类型声明的自动更新与注入,便于定义自定义 JSX 元素并改善编译时类型校验。
    • 模板中新增用于增强全局 JSX 类型的声明文件,支持在组件中识别自定义标签。
  • Chores
    • 增加构建后处理脚本与包配置,确保生成的 JSX 类型声明被复制到发布产物并通过包元数据对外公布。

@coderabbitai
Copy link

coderabbitai bot commented Nov 10, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

为砖块生成器添加对 JSX 类型声明的支持:在生成流程中新增更新 jsx.d.ts 的 plop 操作,新增 jsx.d.ts 模板,修改 package 模板以输出并导出该声明文件,并新增独立脚本在构建后复制 src/jsx.d.tsdist-types/jsx.d.ts

Changes

队列 / 文件 变更摘要
生成器操作
packages/yo/src/plopfile.js
添加 updateJsxDts 异步操作:读取或初始化 jsx.d.ts,基于 answers 计算 tagName/className/propName,生成 import 与类型声明片段,使用正则插入并写回文件,包含错误处理与失败检查。
package 模板(类型导出与构建流程)
packages/yo/src/templates/bricks/package.json.hbs
在 package 模板中新增顶层 "types": "dist-types/jsx.d.ts",在 exports 中添加 ".": "./dist-types/jsx.d.ts" 映射;将 build:types 脚本扩展为在 tsc ... 后执行 copy-jsx-d-ts
TS 声明模板
packages/yo/src/templates/bricks/src/jsx.d.ts.hbs
新增全局类型声明模板文件:通过 declare global { namespace JSX { interface IntrinsicElements { /* ... */ } } } 扩展 JSX.IntrinsicElements,作为占位供生成的砖块类型注入。
复制脚本
packages/build-next-bricks/bin/copy-jsx-d-ts.js
新增 Node 可执行脚本:检测 src/jsx.d.ts 是否存在,若存在则复制到 dist-types/jsx.d.ts,包含日志与错误处理,脚本带 shebang 并立即执行。
构建包配置
packages/build-next-bricks/package.json
bin 字段添加 copy-jsx-d-ts: "./bin/copy-jsx-d-ts.js" 可执行映射(保留现有其它映射)。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • 关注点:
    • plopfile.js 中用于查找/插入标记的正则表达式是否稳健、是否能处理边界与多次运行场景;
    • updateJsxDts 的异步文件读写与错误处理路径(不存在文件、并发执行、权限问题);
    • packages/yo/src/templates/bricks/package.json.hbs 中新增 typesexports 映射是否符合预期的 package 导出策略;
    • copy-jsx-d-ts.js 在不同平台(Windows、POSIX)路径与执行环境的兼容性及错误信息可读性;
    • 构建脚本将 copy-jsx-d-ts 作为后置命令是否在所有 CI/构建环境中可用(可执行权限、Node 可用性)。

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive PR描述包含完整的模板结构,涵盖了依赖检查和提交信息检查等必要部分,但未勾选任何具体选项且缺少简单描述。 请勾选适当的检查项以明确本次MR的性质,并在'## 简单描述'部分补充说明所做的具体工作。
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR标题 'fix(): add jsx.d.ts' 清晰准确地描述了本次更改的主要内容,即添加jsx.d.ts功能来修复问题。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steve/v3-jsx

📜 Recent 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 769bcb9 and 38d794b.

📒 Files selected for processing (5)
  • packages/build-next-bricks/bin/copy-jsx-d-ts.js (1 hunks)
  • packages/build-next-bricks/package.json (1 hunks)
  • packages/yo/src/plopfile.js (1 hunks)
  • packages/yo/src/templates/bricks/package.json.hbs (2 hunks)
  • packages/yo/src/templates/bricks/src/jsx.d.ts.hbs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/build-next-bricks/package.json
  • packages/yo/src/templates/bricks/src/jsx.d.ts.hbs
  • packages/build-next-bricks/bin/copy-jsx-d-ts.js

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.

@cypress
Copy link

cypress bot commented Nov 10, 2025

next-core    Run #11793

Run Properties:  status check passed Passed #11793  •  git commit dd03c739c0 ℹ️: Merge 38d794be0a8a59df4364159cc6a1be074670b8a5 into 30de503f4f8d9eea764201203c50...
Project next-core
Branch Review steve/v3-jsx
Run status status check passed Passed #11793
Run duration 00m 26s
Commit git commit dd03c739c0 ℹ️: Merge 38d794be0a8a59df4364159cc6a1be074670b8a5 into 30de503f4f8d9eea764201203c50...
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 ↗︎

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 adds JSX TypeScript declaration support for brick components by introducing a jsx.d.ts file that extends JSX intrinsic elements. When a new brick is created, the file is automatically updated with type definitions for the brick.

  • Introduces a new jsx.d.ts.hbs template file with JSX type declaration boilerplate
  • Updates the build:types script to copy jsx.d.ts to the output directory
  • Adds an updateJsxDts function in plopfile.js to automatically update JSX type definitions when creating new bricks

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
packages/yo/src/templates/bricks/src/jsx.d.ts.hbs New template file providing JSX type declaration structure for brick components
packages/yo/src/templates/bricks/package.json.hbs Updated build:types script to include jsx.d.ts in the build output
packages/yo/src/plopfile.js Added updateJsxDts action to automatically generate and update JSX type definitions when creating bricks

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


let newJsxDts = jsxDtsContent;
for (const [pattern, replacement] of replacementPatterns) {
newJsxDts = jsxDtsContent.replace(pattern, replacement);
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The regex replacement uses jsxDtsContent instead of newJsxDts on line 362. This causes the second pattern replacement to always fail because it's applying to the original content instead of the result of the first replacement. Change jsxDtsContent.replace to newJsxDts.replace.

Suggested change
newJsxDts = jsxDtsContent.replace(pattern, replacement);
newJsxDts = newJsxDts.replace(pattern, replacement);

Copilot uses AI. Check for mistakes.
"build": "npm run build:main && npm run build:types",
"build:main": "cross-env NODE_ENV=production build-next-bricks",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cp src/jsx.d.ts dist-types/jsx.d.ts",
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The cp command will fail on Windows systems. Consider using cross-env (which is already a dependency) with a cross-platform copy command, or use a Node.js-based copy solution. For example, you could use cpy-cli or create a small Node script to handle the copy operation.

Suggested change
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cp src/jsx.d.ts dist-types/jsx.d.ts",
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cpy-cli src/jsx.d.ts dist-types/jsx.d.ts",

Copilot uses AI. Check for mistakes.
],
[
// eslint-disable-next-line no-regex-spaces
/(\r?\n)( \}\r?\n \}\r?\n\}\r?\n)$/,
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The regex pattern uses hard-coded spaces (4 spaces, 2 spaces) which is fragile and will break if the template's indentation changes. Consider using \s* for flexible whitespace matching or extracting the expected structure as a constant with documentation explaining the pattern.

Suggested change
/(\r?\n)( \}\r?\n \}\r?\n\}\r?\n)$/,
/(\r?\n)(\s*\}\r?\n\s*\}\r?\n\}\r?\n)$/,

Copilot uses AI. Check for mistakes.
],
];

let newJsxDts = jsxDtsContent;
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

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

The initial value of newJsxDts is unused, since it is always overwritten.

Suggested change
let newJsxDts = jsxDtsContent;
let newJsxDts;

Copilot uses AI. Check for mistakes.
@weareoutman weareoutman merged commit 70e8527 into v3 Nov 10, 2025
8 checks passed
@weareoutman weareoutman deleted the steve/v3-jsx branch November 10, 2025 05:06
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