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
Bundle size optimization for v5 #39900
Comments
You may look for issues: |
|
Use ES classes, remove these babel plugins: https://github.com/ant-design/antd-tools/blob/3b3447eb106a80ebc64e634ca60ce1cd55e8a351/lib/getBabelCommonConfig.js#L20-L22 |
重构完 Transfer 组件的三个文件,一共少了大约 800 b |
重构工作就剩下 Affix 组件了,这个组件只有一个文件,但是逻辑比较复杂 |
按官方支持范围,是的:https://caniuse.com/es6-class |
antd 里同一个 icon,套了几层娃,好几个文件。相比 mui,一个图标只有一个文件:https://www.npmjs.com/package/@material-ui/icons?activeTab=explore |
计划把 |
除了 |
哦,原来已经提取过了,那改造一下上面的代码即可:https://github.com/react-component/upload/blob/0d0ca2f65acca13f64199ffbb05054fb13c210ea/src/AjaxUploader.tsx#L303 antd 里也有: |
Practice shows that in a real project, no more than 30-50% of the components are actually used, and even those are heavily customized. Mentions, |
Probably this would be better for v6 instead, but IMO, if we want the most optimized bundle size, we should mostly "offload" to consumers. For example, this button loading icon: ant-design/components/button/button.tsx Line 251 in 3bbe9e7
What I think is, if consumers want to add loading spinners to the button (to indicate loading/submitting/something), then they would add it themselves. If they are using Button in the code but never use the Maybe we can have something like <PlainButton>
{isLoading ? <AntdLoadingIcon /> : null}
Submit
</PlainButton>
<Button loading={isLoading}>Submit</Button> |
This is a micro-optimization, although it's a valid point that relates to how the styling of Ant's projects is tightly coupled with the Ant Design design system. For example, if they need an icon to be on the left, such a property will be available in the design system, but if they don't, it won't be there. For example, do you know how to add an icon to Button on the right or align an arrow in the center of Accordion, find an H6 heading, or explain the purpose of exotic components that you would never be able to use in your own projects? Currently, Ant Design is one of the heaviest libraries, and it still has significant issues with optimization, mobile device adaptation, and accessibility. Therefore, first and foremost, they need to understand how they want to position their system in order to avoid closing tickets they disagree with, not releasing backward-incompatible releases in minor versions, not passing beta versions off as major releases (currently, tokens don't work well) and start testing. I tend to believe that a few years ago Ant Design were monopolists in the design system market, with no one else having as many visually pleasing components. However, now there are numerous libraries and standards with high competition, and performance is one of the crucial tasks. Here's how I see the steps that could help solve this problem:
|
Fork and use father to build. |
比起 https://unpkg.com/browse/lucide-react@0.360.0/dist/esm/icons/zap.js Ant Design Icons 的冗余代码要多好多。 |
We did it in #38720 before, and continue it recently.
Here is the current bundle size: #39898 (comment)
./dist/antd.min.js
./dist/antd-with-locales.min.js
report.html.zip
Since we drop legacy browsers support, there are still something we can optimize.
The text was updated successfully, but these errors were encountered: