-
Notifications
You must be signed in to change notification settings - Fork 587
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
esm模式按需引入模式失效 #307
Comments
或者我不打包自己的Icon组件,在任意项目中直接引 @ant-design/icons/es/index.js下的createFromIconfontCN去创造的Icon组件,一样有此问题 |
production 模式下 webpack 才会 tree shaking |
我是使用father build开发一个组件库A。 其中有Button、Affix、Icon等。我用build + npm pack的方式将A打包后的tgz,在项目B npm install使用,而不是link使用。Button、Affix等都是按照预料做了按需,没有加载什么多余内容。但是通过createFromIconfontCN创建的Icon就是我刚才截图的情况。 |
以上是我的猜测,除非你能提供可重现的 demo,不然只能是猜测。 |
好的。我晚点给个复现库。 |
@ant-design/icons这个包还是有问题吧。虽然官网的示例是按需打包了,但是我也遇到了题主同样的bug。 我不断的删除文件,发现没有页面引用了,它还是全量打包。 |
myantdpro.zip |
我来修一下 |
遇到同样问题,等待进展 |
@chenshuai2144 这个问题修复的怎么样了?我们也遇到了同样的问题,需不需要我们来帮忙修复,期待回复。 |
1年了,按需加载还没解决,是放弃ant-design了吗? |
已经休掉了,不过最近又有 bug 复现了,马上会解决一下 4.113 版本 |
@chenshuai2144 OK,我看到4.11.2已经发布了,期待4.11.3哈,我正好在做性能优化,所以这里很关键。 |
发了4.12.0, 你试试 |
这个问题在4.16.2版本又出现了🙏 |
应该是同一个问题吧 官方已经修复 ant-design/ant-design#31008 |
已解决, many thx |
Any news on this? Seems like tree shaking isn't working. |
遇到同样问题,有人找到解法么,求分享 |
try this: ant-design/ant-design#12011 (comment) |
Tried this and not working |
我感觉还是有问题啊。antd本身又lib 又有es的方式导入,导致我都不知道改如何导入字体库了。 我都使用全路径了。 |
2023年了,这个问题可以了吗 |
import { DownloadOutlined } from '@ant-design/icons';
console.log(DownloadOutlined); 用 Node.js 18 跑单元测试:
但 v5.2.x 又不支持了:
|
I also had the
problem with version 5.2.x and Node v 20. Downgrading to 5.1.4 fixed the problem. |
2024了,这个问题可以了吗? |
2024 年了 这个问题解决了么 |
快2025 年了 这个问题解决了么 |
@Liian123 @xiaojingyuaner @Tonyangl 这个问题还存在么?是否能提供重现? |
当我在vite 5.1.0 和remix2 中使用时,导入图标组件会报错,以下是报错信息;当使用"@ant-design/icons": "5.1.4" 版本则没问题。 [vite] Named export 'UserOutlined' not found. The requested module '@ant-design/icons' is a CommonJS module, which may not support all module.exports as named exports. import pkg from '@ant-design/icons'; |
看上去是 #605 这个问题。 |
你好,我在自己的组件中引用了 @ant-design/icons/es/index.js下的
createFromIconfontCN
方法,伪代码大致这样:打包成组件后,在另一个项目引用它,在那儿经webpack analyzer发现,整个Icon包1.23mb的东西都被引进来了👇
![image](https://user-images.githubusercontent.com/11535146/83290652-8952ab80-a219-11ea-88fd-1446c0500323.png)
The text was updated successfully, but these errors were encountered: