Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: esm/cls browser targets #282

Merged
merged 2 commits into from
Dec 1, 2024
Merged

perf: esm/cls browser targets #282

merged 2 commits into from
Dec 1, 2024

Conversation

afc163
Copy link
Member

@afc163 afc163 commented Nov 30, 2024

#234 里把 esm 和 cjs 的 targets 移除了,给 umd 加上了 targets,确实降低了 dist 的文件大小,但是把 bundlephobia 里的体积搞大了。

这里都加上。

Summary by CodeRabbit

  • 新功能
    • 添加了针对 Chrome 80 的新浏览器目标配置。
  • 变更
    • 移除了之前在 UMD 部分的浏览器目标配置。

Copy link
Contributor

coderabbitai bot commented Nov 30, 2024

📝 Walkthrough

Walkthrough

此次更改在 .fatherrc.ts 文件中引入了新的 targets 配置部分,指定目标浏览器为 Chrome 80。之前位于 umd 部分的 targets 配置已被移除。CodecovWebpackPlugin 类保持不变,构造函数和 apply 方法未做修改。esmcjsumd 的整体配置结构保持不变,输入路径、忽略项和外部依赖没有修改。chainWebpack 函数继续根据 NODE_ENV 环境变量有条件地应用 CodecovWebpackPlugin

Changes

文件 更改摘要
.fatherrc.ts 新增 targets: { chrome: 80 } 配置,移除 umd 部分的相应配置。

Possibly related PRs

  • perf: Update browser targets #234: 此 PR 也修改了 .fatherrc.ts 文件,特别是为 Chrome 80 添加了 targets 属性,直接与主 PR 中的 targets 配置更改相关。

Suggested reviewers

  • YumoImer

Poem

在兔子的耳边轻声说,
新的目标已到手,
Chrome 80,真不错,
配置更新真是妙!
兔子欢跳不觉累,
一起欢庆这变化! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Nov 30, 2024

Preview is ready

Copy link

codecov bot commented Nov 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.13%. Comparing base (8ffbef6) to head (910127e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #282   +/-   ##
=======================================
  Coverage   91.13%   91.13%           
=======================================
  Files          66       66           
  Lines        1422     1422           
  Branches      364      379   +15     
=======================================
  Hits         1296     1296           
  Misses        126      126           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codecov bot commented Nov 30, 2024

Bundle Report

Bundle size has no change ✅

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
.fatherrc.ts (2)

22-24: 建议:考虑更细粒度的浏览器目标配置

目前的配置仅指定了 Chrome 80,建议考虑:

  1. 为不同的构建格式(ESM/CJS/UMD)设置差异化的目标
  2. 添加其他主流浏览器的支持
 targets: {
-  chrome: 80,
+  chrome: 80,
+  firefox: 74,
+  safari: '13.1',
+  edge: 80
 },

22-24: 建议:监控包大小变化

为了确保此更改达到预期效果,建议:

  1. 在合并前使用 Bundlephobia 验证包大小变化
  2. 建立包大小基准测试流程
  3. 考虑添加包大小限制检查

这将帮助团队及时发现和解决包大小问题。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9ddf51c and e867339.

📒 Files selected for processing (1)
  • .fatherrc.ts (1 hunks)
🔇 Additional comments (1)
.fatherrc.ts (1)

22-24: 浏览器目标配置的调整需要验证

targets 配置从 umd 部分移至根级别会影响所有构建格式(ESM、CJS、UMD)。这个改动可能会帮助优化包大小,但需要验证是否会影响到浏览器兼容性。

运行以下脚本来分析当前的包大小:

✅ Verification successful

浏览器目标配置调整是合理的优化

根据分析,这个改动是安全且合理的:

  • package.json 中已设置 browserslist: ["defaults"] 作为基础兼容性配置
  • 项目依赖中包含 browserslist-to-esbuild,说明构建工具链已具备正确处理目标浏览器配置的能力
  • 从 CHANGELOG 可见,项目此前就在持续优化包大小和浏览器兼容性策略
  • Chrome 80 是一个合理的目标版本,可以支持现代 JavaScript 特性同时保持良好的兼容性
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: 分析包大小变化

# 检查 dist 目录下的文件大小
fd -e js -e css . dist/ --exec du -h {}

# 检查 package.json 中的浏览器目标配置
cat package.json | jq '.browserslist'

Length of output: 191


Script:

#!/bin/bash
# 检查项目中的其他构建配置文件
fd -e ts -e js -e json . -t f --exec grep -l "browserslist\|targets" {}

# 检查是否有 .browserslistrc 配置文件
fd "\.browserslistrc$"

# 检查 package.json 中的构建相关配置
cat package.json | jq '{dependencies,devDependencies,peerDependencies,browserslist}'

# 搜索代码库中可能的浏览器兼容性相关配置
rg -i "browser.*support|browser.*target|browserslist|chrome.*version" -g '!{node_modules,dist}/*'

Length of output: 7598

Copy link

github-actions bot commented Nov 30, 2024

size-limit report 📦

Path Size
dist/antdx.min.js 40.53 KB

Copy link

cloudflare-workers-and-pages bot commented Nov 30, 2024

Deploying ant-design-x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 910127e
Status: ✅  Deploy successful!
Preview URL: https://c148244f.ant-design-x.pages.dev
Branch Preview URL: https://perf-browser-target.ant-design-x.pages.dev

View logs

@YumoImer YumoImer merged commit 9e8234d into main Dec 1, 2024
15 checks passed
@YumoImer YumoImer deleted the perf/browser-target branch December 1, 2024 07:01
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.

2 participants