[v5] remove `es` dir for better import
See original GitHub issueWhat problem does this feature solve?
Since we want to remove lib
and focus on ESM only, it is better remove es
dir.
Then we can:
import Button from 'antd/button';
instead of:
import Button from 'antd/es/button';
and have a better tree shaking experience.
What does the proposed API look like?
import Button from 'antd/button';
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
New Features v5 and Migration from v4 - React Suite
For better accessibility, we decided to prefer SVG Icon. And can be well compatible with third-party icon resources. import GearIcon from '@rsuite/icons ...
Read more >V4 to V5 - Ant Design
CSS-in-JS itself has the ability to import on demand, and plugin support is no longer required. Umi users can remove related configurations.
Read more >Migrating to v5: getting started - Material UI - MUI
This guide explains how and why to migrate from Material UI v4 to v5.
Read more >v5 used to include polyfills for node.js core modules by default
Module not found: Error: You attempted to import ... If no - Then remove the package and find an alternative package better suited....
Read more >Instead change the require of index.js, to a dynamic import ...
and istead of writing require('chalk') in js file change it to import ... of ES Module /Users/myname/Documents/mydir/anotherdir/my-project/ ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why not
import { Button } from 'antd';
?关于你说的这个问题,我深表理解。
题主之所以不喜欢
import { Button } from 'antd'
的语法,一个重要的原因,是因为这样tree shaking
体验很差。在
Vite
中,像上面这样简写的解构导入,会在打包时让Rollup
去分析整个antd
包,从而极大的拖慢打包速度。若改成
import Button from 'antd/es/button'
,则打包速度可以飞跃提升。但这种写法,实在是很啰嗦,好在,有一个插件
vite-plugin-imp
,可以帮我们自动转换这种写法,并自动引入样式。其实它就是
babel-plugin-import
的Vite
版,给你参考一下我的配置,希望对你有帮助。另外,这个问题其实并不关
antd
的事,删除lib
目录只留es
目录更是duck不必。