Skip to content

build: 拥抱esm新规范和tailwind新版本#202

Merged
lucienshawls merged 27 commits intoMaaAssistantArknights:devfrom
lucienshawls:build/esm
Nov 5, 2025
Merged

build: 拥抱esm新规范和tailwind新版本#202
lucienshawls merged 27 commits intoMaaAssistantArknights:devfrom
lucienshawls:build/esm

Conversation

@lucienshawls
Copy link
Contributor

@lucienshawls lucienshawls commented Nov 3, 2025

  1. package.json 中添加 type: module,默认视为 ESM
    • 现在 js 文件默认视为 esm 而非之前的 cjs,故重命名相关文件,更改扩展名
    • 更改所有的 js 文件的语法,适配 ESM 规范(这还包括 eslint 和 prettier 等的配置文件)
    • 更改 package 元数据
  2. 升级 tailwindcss 到 v4,并适应新版本的以下破坏性更新:
    • 使用官方升级工具,自动对部分过时的 class 名称进行修改
    • 更改了其与 postcss 和 vite 的集成方式
    • 其默认支持 autoprefixer,移除 postcss 的对应插件
    • 边框的默认颜色被修改,经检查仓库中每处 border 都指定了颜色,无需适应此改动
    • css 的 hidden 不再被 flex/block 覆盖,导致友链的消失动画出现异常,已移除 css 对显隐的控制备份
    • 鼠标指针悬浮在按钮上的默认图标被修改,已添加设置覆盖(新版默认为平常状态的指针,现改回了手型)
    • 不再推荐使用 tailwind.config.js 作为配置文件,已删除
    • 上述配置文件中,有两个关键设置:
      • 设置了暗黑模式的切换方式,已在 css 中用推荐方法配置(但引入了非css标准语法,导致编辑器警告)
      • 设置了过渡动画的默认持续时间,经检查所有切换动画都原地手动指定了持续时间,默认值从未被使用,无需适配
  3. 更新 devcontainer 环境
    • 引入新扩展:ES7+ React/Redux/React-Native snippets
    • 引入新扩展:Tailwind CSS IntelliSense
    • 使默认 css 检查器忽略特定类型的警告(解决因设置暗黑模式切换方式导致的警告)
    • 调整 pnpm 的安装时机,原本作为镜像构建的一部分,现移到安装后脚本中(后者可与仓库文件交互,前者不行)
  4. 更新构建方法
    • pnpm 不需要 corepack(自己就有版本控制),因此仅调整 devcontainer 中,pnpm 的安装时机
  5. 更新部分依赖的版本
  6. 更新文档
  7. 修复 eslint 报错
  8. 更新工作流
    • 不允许非 dev 分支的 push 触发工作流
    • 允许由 pr 触发工作流检查
    • 非手动运行时额外进行 eslint 代码格式检查,但不因此使工作流失败,出错时设置警告

@AnnAngela
Copy link
Member

最支持的一集

@lucienshawls lucienshawls marked this pull request as ready for review November 3, 2025 14:13
@lucienshawls lucienshawls requested a review from a team November 3, 2025 14:13
@AnnAngela
Copy link
Member

我看看能不能写个ci跑跑看

@lucienshawls

This comment was marked as outdated.

Copy link
Member

@SherkeyXD SherkeyXD left a comment

Choose a reason for hiding this comment

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

LGTM

@AnnAngela

This comment was marked as outdated.

@lucienshawls

This comment was marked as outdated.

@lucienshawls

This comment was marked as outdated.

@lucienshawls
Copy link
Contributor Author

@AnnAngela AnnAngela requested a review from Copilot November 3, 2025 16:11
Copy link
Contributor

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 upgrades the project to use Tailwind CSS v4 with its new compilation tooling and migrates the codebase to ES modules. Key changes include:

  • Upgrade Tailwind CSS from v3 to v4, replacing autoprefixer with @tailwindcss/postcss and @tailwindcss/vite
  • Migrate from CommonJS to ES modules across configuration files
  • Update dependencies (React 19.2, TypeScript 5.9.3, various build tools)
  • Add missing dependency arrays to React hooks for proper effect re-execution
  • Modernize Tailwind utility classes to align with v4 conventions

Reviewed Changes

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

Show a summary per file
File Description
pnpm-workspace.yaml Added onlyBuiltDependencies configuration for esbuild
pnpm-lock.yaml Updated lockfile reflecting all dependency upgrades
package.json Added ES module type, updated turbo version, renamed bundler script
bundler.js Changed to default import for ES module compatibility
apps/web/vite.config.ts Added Tailwind CSS Vite plugin
apps/web/tsconfig.json Updated for ES modules, added build cache path and types
apps/web/tailwind.config.js Removed legacy Tailwind v3 configuration file
apps/web/postcss.config.js Migrated to ES module and updated for Tailwind v4
apps/web/package.json Upgraded dependencies and added ES module type
apps/web/eslint.config.js Complete rewrite for ES modules with flat config structure
apps/web/src/index.css Updated to Tailwind v4 import syntax and custom variant
apps/web/src/vite-env.d.ts Removed redundant type reference (moved to tsconfig)
Component files Fixed missing dependency arrays and updated class names to v4 conventions
.pre-commit.prettierrc.js Rewritten as ES module with async plugin loading
.pre-commit.prettierrc.cjs Removed CommonJS version
.github/workflows/deploy.yml Added lint check step and improved checkout configuration
.devcontainer/* Simplified setup by removing custom Dockerfile

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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lucienshawls
Copy link
Contributor Author

你们说要不要也加个 pre-commit 来自动格式化?配置文件已经设置好了,只要在仓库设置里添加一下 pre-commit.ci 的应用就行了(

https://github.com/apps/pre-commit-ci/installations/select_target

不过可能得有更高权限才能配置

@AnnAngela
Copy link
Member

你可以先写,写好后摇人加上就行

@lucienshawls
Copy link
Contributor Author

你可以先写,写好后摇人加上就行

已经写好,在自己的仓库测试过了,没有问题

@MistEO 可以在这个仓库装 pre-commit.ci 应用了:

https://github.com/apps/pre-commit-ci/installations/select_target

@lucienshawls lucienshawls requested a review from MistEO November 4, 2025 03:37
@lucienshawls lucienshawls merged commit 6f20c0b into MaaAssistantArknights:dev Nov 5, 2025
1 check passed
@lucienshawls lucienshawls deleted the build/esm branch November 5, 2025 07:48
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.

3 participants