chore(deps): bump @babel from 7.4.5 to 8.0.0#294
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough将 ChangesBabel 8 升级与防御性代码改进
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub. |
There was a problem hiding this comment.
Code Review
This pull request upgrades Babel and related dependencies to version 8, adds optional chaining and existence checks to prevent potential runtime errors, and reformats several conditional statements. The review feedback suggests renaming and upgrading @babel/plugin-proposal-class-properties to @babel/plugin-transform-class-properties to align with Babel 8 conventions, and optimizing the array and Set operations in src/apiCollection.ts to avoid excessive allocations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s Babel/Jest-related dependency stack and adjusts a few TypeScript call sites to satisfy updated typings (e.g., optional properties and updated type exports) as part of the dependency bump.
Changes:
- Bumps multiple Babel-related packages (and related tooling like
babel-jest,babel-loader,babel-plugin-import) to newer major versions. - Updates several code paths to handle possibly-undefined properties (
?.) and to use updated Babel/Jest TypeScript types. - Adds a defensive check around
config.outputmutations in the production webpack config path.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/CleanUpStatsPlugin.ts | Makes stats cleanup logic tolerant of optional child.name and reformats warning filtering. |
| src/sortApiTable.ts | Makes AST traversal tolerate missing children (now optional). |
| src/jest/codePreprocessor.ts | Updates Babel plugin typing and casts config to babel-jest’s transformer config type. |
| src/getWebpackConfig.ts | Guards config.output mutations behind an existence check. |
| src/apiCollection.ts | Expands early returns to blocks and adds explicit generic typing for Set. |
| package.json | Major bumps Babel-related dependencies and related tooling; removes @types/babel__core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/jest/codePreprocessor.ts (1)
56-68:⚠️ Potential issue | 🔴 Critical
createTransformer返回联合类型未做类型收窄,process属性访问在类型检查阶段失败。第 59 和 62 行的 TS2339 编译错误已确认:
createTransformer返回SyncTransformer<TransformerConfig> | Promise<SyncTransformer<TransformerConfig>>,但代码未对联合类型进行收窄即直接访问process属性。需在使用前添加类型守卫来确保返回的是同步transformer。修复方案
const babelSupport = /\.(t|j)sx?$/.test(filePath); const babelJest = createTransformer(babelConfig as TransformerConfig); + if (typeof (babelJest as Promise<unknown>).then === 'function') { + throw new Error('createTransformer returned Promise, but sync process() is required here.'); + } const name = babelSupport ? filePath : 'file.js';🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/jest/codePreprocessor.ts` around lines 56 - 68, The babelJest variable returned from createTransformer is a union type that could be either a SyncTransformer or a Promise of SyncTransformer, but the code immediately accesses the process property without type narrowing, causing TS2339 errors on lines 59 and 62. Add a type guard to check that babelJest is not a Promise before accessing its process property. You can use an if statement with instanceof Promise check or another appropriate type assertion to ensure the value is a synchronous transformer before proceeding with the process method call.Source: Pipeline failures
src/getWebpackConfig.ts (1)
42-46:⚠️ Potential issue | 🔴 Critical
babelConfig.plugins的类型契约不完整,导致 TypeScript 编译错误阻塞 CI。
getBabelCommonConfig函数返回对象包含plugins属性(第 59 行),但BabelConfig接口没有显式声明plugins属性。虽然BabelConfig扩展了TransformOptions,但在调用端(第 42-46、56、68 行)访问babelConfig.plugins.push()时,TypeScript 无法推断该属性,导致 TS2339 错误。建议在
src/getBabelCommonConfig.ts的BabelConfig接口中显式添加plugins属性声明,或在返回类型中使用更精确的类型注解,确保类型与实际返回值一致。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/getWebpackConfig.ts` around lines 42 - 46, The BabelConfig interface does not explicitly declare the plugins property, even though getBabelCommonConfig returns an object that has this property, causing TypeScript type errors when accessing babelConfig.plugins.push(). Fix this by either adding an explicit plugins property declaration (with the correct type) to the BabelConfig interface in src/getBabelCommonConfig.ts, or by updating the return type annotation of the getBabelCommonConfig function to accurately reflect that the returned object includes a plugins property with the appropriate array type. This will ensure TypeScript can properly infer the type when accessing and manipulating babelConfig.plugins across all calling locations.Source: Pipeline failures
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 50: The babel-jest package at version ^30.4.1 has a mismatched major
version with the jest package at ^27.0.3. To fix this incompatibility, you must
align the major versions of both packages. Either upgrade the jest package to
version 30.x to match babel-jest, or downgrade babel-jest to version 27.x to
match jest. Ensure both packages have the same major version number after making
the change.
---
Outside diff comments:
In `@src/getWebpackConfig.ts`:
- Around line 42-46: The BabelConfig interface does not explicitly declare the
plugins property, even though getBabelCommonConfig returns an object that has
this property, causing TypeScript type errors when accessing
babelConfig.plugins.push(). Fix this by either adding an explicit plugins
property declaration (with the correct type) to the BabelConfig interface in
src/getBabelCommonConfig.ts, or by updating the return type annotation of the
getBabelCommonConfig function to accurately reflect that the returned object
includes a plugins property with the appropriate array type. This will ensure
TypeScript can properly infer the type when accessing and manipulating
babelConfig.plugins across all calling locations.
In `@src/jest/codePreprocessor.ts`:
- Around line 56-68: The babelJest variable returned from createTransformer is a
union type that could be either a SyncTransformer or a Promise of
SyncTransformer, but the code immediately accesses the process property without
type narrowing, causing TS2339 errors on lines 59 and 62. Add a type guard to
check that babelJest is not a Promise before accessing its process property. You
can use an if statement with instanceof Promise check or another appropriate
type assertion to ensure the value is a synchronous transformer before
proceeding with the process method call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bf72ec94-5715-405a-8997-c5e7146310e2
📒 Files selected for processing (6)
package.jsonsrc/apiCollection.tssrc/getWebpackConfig.tssrc/jest/codePreprocessor.tssrc/sortApiTable.tssrc/utils/CleanUpStatsPlugin.ts
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/getWebpackConfig.ts (1)
46-69:⚠️ Potential issue | 🟠 Major | ⚡ Quick win应避免静默跳过 Babel 插件注册(会改变构建行为)
Line 46、Line 56、Line 68 这里改成
plugins?.push(...)后,如果babelConfig.plugins为undefined,构建不会报错,但会悄悄丢失babel-plugin-import/replaceLib,导致产物行为变化。建议在第一次使用前显式初始化plugins,再统一push。建议修复(保持防御性且不丢功能)
+ const plugins = (babelConfig.plugins ??= []); - - babelConfig.plugins?.push([ + plugins.push([ resolve('babel-plugin-import'), { style: true, libraryName: pkg.name, libraryDirectory: 'components', }, ]); if (pkg.name !== 'antd') { - babelConfig.plugins?.push([ + plugins.push([ resolve('babel-plugin-import'), { style: 'css', libraryDirectory: 'es', libraryName: 'antd', }, 'other-package-babel-plugin-import', ]); } if (modules === false) { - babelConfig.plugins?.push(require.resolve('./replaceLib')); + plugins.push(require.resolve('./replaceLib')); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/getWebpackConfig.ts` around lines 46 - 69, The code uses optional chaining with push (plugins?.push()) which silently fails if babelConfig.plugins is undefined, causing babel plugins like babel-plugin-import and replaceLib to not be registered without any error. Initialize babelConfig.plugins as an empty array if it's undefined before the first push operation, then consistently use babelConfig.plugins.push() across all three plugin registration locations (the initial babel-plugin-import registration, the conditional antd babel-plugin-import registration, and the replaceLib plugin registration) to ensure all plugins are properly registered and the build behavior remains consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/getWebpackConfig.ts`:
- Around line 46-69: The code uses optional chaining with push (plugins?.push())
which silently fails if babelConfig.plugins is undefined, causing babel plugins
like babel-plugin-import and replaceLib to not be registered without any error.
Initialize babelConfig.plugins as an empty array if it's undefined before the
first push operation, then consistently use babelConfig.plugins.push() across
all three plugin registration locations (the initial babel-plugin-import
registration, the conditional antd babel-plugin-import registration, and the
replaceLib plugin registration) to ensure all plugins are properly registered
and the build behavior remains consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: db07bc34-e0fc-47ef-a25d-f3297c73fff3
📒 Files selected for processing (8)
package.jsonsrc/getBabelCommonConfig.tssrc/getWebpackConfig.tssrc/global.d.tssrc/jest/codePreprocessor.tssrc/jest/demoPreprocessor.tssrc/replaceLib.tssrc/sortApiTable.ts
✅ Files skipped from review due to trivial changes (2)
- src/global.d.ts
- src/replaceLib.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/sortApiTable.ts
- package.json
- src/jest/codePreprocessor.ts
|
看看 babel runtime 是哪里还需要,我记得 @zombieJ 干掉过。 |
这个 PR 在做什么这个 PR 将 Babel 主链路升级到 8.x,同时升级 Jest / babel-jest / babel-loader,并调整了一些 Babel/Jest 类型与防御性空值处理。CI 当前显示 pass,但 diff 只改了 结论不适合合并 依赖升级链路还不完整:lockfile 没更新,编译链路里的 问题清单🔴 高优先级(阻塞合并)
🟡 中优先级(建议修复)
🟢 低优先级(可选改进)无。 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/gulpfile.ts (1)
148-156:⚠️ Potential issue | 🔴 Criticalgulp-babel 8.0.0 与 Babel 8 存在 peer dependency 冲突。
根据 npm 注册表查询结果,gulp-babel 8.0.0 的 peer dependency 要求为
@babel/core ^7.0.0,但该 PR 目标是升级到 Babel 8(即@babel/core ^8.0.0)。这意味着当前的配置会产生 peer dependency 冲突,导致构建失败。需要升级到支持 Babel 8 的 gulp-babel 版本(8.1.0 或更高),或确认 PR 中是否有相应的 gulp-babel 版本更新。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/gulpfile.ts` around lines 148 - 156, The current setup has a peer dependency conflict: gulp-babel 8.0.0 requires `@babel/core` ^7.0.0, but the PR is upgrading to Babel 8 (`@babel/core` ^8.0.0). The babelify function in gulpfile.ts uses the babel() function from gulp-babel, so you need to ensure compatibility. Update the gulp-babel package version in package.json to 8.1.0 or higher which supports Babel 8, then verify the babelify function and its babel() invocation will work correctly with the new version. This resolves the peer dependency conflict and allows the build to proceed without errors.
🧹 Nitpick comments (1)
src/gulpfile.ts (1)
152-152: 💤 Low value可选链略显防御性但可接受。
从
getBabelCommonConfig的实现可知,返回的babelConfig.plugins始终是一个数组而非 undefined。此处的可选链plugins?.push虽然略显过度防御,但不影响功能且提升了代码健壮性。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/gulpfile.ts` at line 152, The optional chaining operator used in the push call to babelConfig.plugins is unnecessarily defensive since getBabelCommonConfig always returns a plugins property as an array that is never undefined. Remove the optional chaining operator from the plugins?.push call in the babelConfig initialization and simply use plugins.push directly, since the property is guaranteed to exist and be an array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/gulpfile.ts`:
- Around line 148-156: The current setup has a peer dependency conflict:
gulp-babel 8.0.0 requires `@babel/core` ^7.0.0, but the PR is upgrading to Babel 8
(`@babel/core` ^8.0.0). The babelify function in gulpfile.ts uses the babel()
function from gulp-babel, so you need to ensure compatibility. Update the
gulp-babel package version in package.json to 8.1.0 or higher which supports
Babel 8, then verify the babelify function and its babel() invocation will work
correctly with the new version. This resolves the peer dependency conflict and
allows the build to proceed without errors.
---
Nitpick comments:
In `@src/gulpfile.ts`:
- Line 152: The optional chaining operator used in the push call to
babelConfig.plugins is unnecessarily defensive since getBabelCommonConfig always
returns a plugins property as an array that is never undefined. Remove the
optional chaining operator from the plugins?.push call in the babelConfig
initialization and simply use plugins.push directly, since the property is
guaranteed to exist and be an array.
|
不行,这个 gulp-babel 太老了,8年没发版了,得找个平替 |
Summary by CodeRabbit