Skip to content

feat: 升级到 Node.js 22 和 React 18 (v2.4.0)#26

Merged
sansi-lcj merged 1 commit intomainfrom
feat/node22-react18-upgrade
May 30, 2025
Merged

feat: 升级到 Node.js 22 和 React 18 (v2.4.0)#26
sansi-lcj merged 1 commit intomainfrom
feat/node22-react18-upgrade

Conversation

@sansi-lcj
Copy link
Member

📋 变更概述

本PR将项目升级到最新的 Node.js 22 LTS 版本,并同时升级了React生态系统和相关依赖。

🚀 主要变更

Node.js 升级

  • : Node.js 20.x
  • : Node.js 22.16.0 LTS (Jod)
  • 影响: 更好的性能、新的语言特性支持

React 生态系统升级

  • React: ^16.0.0^18
  • React DOM: ^16.0.0^18
  • @types/react: ^17.0.37^18
  • @types/react-dom: ^17.0.11^18

TypeScript 升级

  • TypeScript: 4.7.4^5.3.0
  • @types/node: ^18.11.17^22.0.0

@realsee 生态系统

  • @realsee/five: 5.0.0-alpha.149^6.4.0-alpha.36
  • @realsee/dnalogel: ^2.19.3^3.67.1

🔧 代码修复

React 18 兼容性修复

  • 修复 VreoProviderProps 接口缺少 children 属性的问题
  • 文件: resources/react/index.tsx

TypeScript 5.x 严格类型检查修复

  • 修复 NodeJS.TimerNodeJS.Timeout 类型问题

  • 文件: __test__/shared-utils/debounce.ts

  • 添加泛型约束 extends Record<string, any>

  • 文件: resources/shared-utils/animationFrame/BetterTween.ts

  • 文件: resources/shared-utils/animationFrame/tween.ts

  • 添加空值检查防止 undefined 错误

  • 文件: resources/Player/modules/keyframes/UpdateVRPanorama/index.tsx

📁 新增文件

  • .nvmrc - Node.js 版本锁定
  • .npmrc - npm 配置
  • .github/workflows/ci.yml - GitHub Actions CI 配置
  • NODE_22_UPGRADE.md - 详细升级文档

⚙️ 配置更新

package.json

{
  "engines": {
    "node": ">=22.0.0",
    "npm": ">=10.0.0"
  }
}

GitHub Actions CI

  • 使用 Node.js 22 进行构建和测试
  • 支持自动依赖缓存

✅ 测试验证

  • 构建成功 (npm run build)
  • 开发服务器启动成功 (npm run dev)
  • 所有依赖成功安装
  • TypeScript 类型检查通过
  • React 18 兼容性确认

🚨 Breaking Changes

⚠️ 重要: 这是一个包含破坏性变更的版本

  1. Node.js 要求: 现在需要 Node.js >= 22.0.0
  2. React 要求: 现在需要 React >= 18
  3. TypeScript: 升级到 5.x,可能影响某些类型检查
  4. API变更: React 18 的某些API变更可能影响使用者

📖 迁移指南

对于开发者

  1. 升级 Node.js 到 22.x: nvm use 22
  2. 清理依赖: rm -rf node_modules package-lock.json
  3. 重新安装: npm install --legacy-peer-deps

对于使用者

  1. 确保您的项目支持 React 18
  2. 更新您的 Node.js 版本到 22.x
  3. 查看 NODE_22_UPGRADE.md 获取详细信息

🔗 相关资源

✨ 下一步

  • 更新项目文档
  • 通知团队成员升级开发环境
  • 更新部署配置使用 Node.js 22

Copy link
Member Author

@sansi-lcj sansi-lcj left a comment

Choose a reason for hiding this comment

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

LGTM

@sansi-lcj sansi-lcj merged commit 59288e3 into main May 30, 2025
1 check passed
@sansi-lcj sansi-lcj deleted the feat/node22-react18-upgrade branch June 3, 2025 13:05
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.

1 participant

Comments