We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://github.com/magicdawn/antd-tree-shaking-demo
只包括 Button
Button
repo main.tsx 为
// import { Button } from 'antd' import Button from 'antd/es/button' console.log(Button)
只使用 Button, pnpm build 后, dist 里有来自 rc-field-form 中的代码, 搜索 (useForm, Form 等
导入链为
好像 rc-field-form 里 RecForm 被 vite/rollup 识别为 side effects
var RefForm = InternalForm; RefForm.FormProvider = FormProvider; RefForm.Field = Field; RefForm.List = List; RefForm.useForm = useForm; RefForm.useWatch = useWatch;
手动修改 node_modules/.pnpm/antd@5.6.1_react-dom@18.2.0_react@18.2.0/node_modules/rc-field-form/es/index.js 为
var RefForm = /*#__PURE__*/ (function () { var f = InternalForm; f.FormProvider = FormProvider; f.Field = Field; f.List = List; f.useForm = useForm; f.useWatch = useWatch; return f })()
后再次打包(pnpm build), 可以看到 useForm 没了. 大小也小了, 562 -> 454, 未 minify 状态下少了 100 kB
$ pb > antd-demo@0.0.0 build /Users/magicdawn/projects/001_learn/antd/antd-demo > tsc && vite build vite v4.3.9 building for production... ✓ 225 modules transformed. dist/index.html 0.40 kB │ gzip: 0.28 kB dist/assets/index-a724464a.js 562.84 kB │ gzip: 130.06 kB ✓ built in 2.16s antd-demo on git main via node v18.14.2 took 4s $ pb > antd-demo@0.0.0 build /Users/magicdawn/projects/001_learn/antd/antd-demo > tsc && vite build vite v4.3.9 building for production... ✓ 225 modules transformed. dist/index.html 0.40 kB │ gzip: 0.28 kB dist/assets/index-05c373d8.js 454.76 kB │ gzip: 108.63 kB ✓ built in 2.30s
期望优化 tree-shaking
包含了未使用的代码(async-validator, form 等)
The text was updated successfully, but these errors were encountered:
ref #42499 #42604
Sorry, something went wrong.
nice ! 坐等新版~
@magicdawn 还没有解法。。
试试 5.6.2-alpha.0,应该好了:
5.6.2-alpha.0
zombieJ
Successfully merging a pull request may close this issue.
Reproduction link
https://github.com/magicdawn/antd-tree-shaking-demo
Steps to reproduce
只包括
Button
repo main.tsx 为
只使用 Button, pnpm build 后, dist 里有来自 rc-field-form 中的代码, 搜索 (useForm, Form 等
导入链为
好像 rc-field-form 里 RecForm 被 vite/rollup 识别为 side effects
手动修改 node_modules/.pnpm/antd@5.6.1_react-dom@18.2.0_react@18.2.0/node_modules/rc-field-form/es/index.js
为
后再次打包(pnpm build), 可以看到 useForm 没了.
大小也小了, 562 -> 454, 未 minify 状态下少了 100 kB
What is expected?
期望优化 tree-shaking
What is actually happening?
包含了未使用的代码(async-validator, form 等)
The text was updated successfully, but these errors were encountered: