问题描述
我正在阅读Material UI文档,它说明:
I'm reading the Material UI documentation, and it states:
我找不到任何为什么使用默认导出使构建过程更快或构建输出更小的理由。
I cannot find any justification for why the use of default exports makes the build process faster or build output smaller.
我的经理要求我们不要使用默认导出,但是更小的构建大小是这个项目的重要目标。我通过Material UI提到了这个引用,他们说要找到证据。我想要一些证据,因为我尝试用Babel编译它已经显示默认
如果有的话更大。
My manager is asking us to refrain from using default exports, however a smaller build size is an important target for this project. I mentioned this quote by Material UI, and they said to find proof. I'd like some proof, please, as my attempts to compile it with Babel have shown default
to be larger if anything.
推荐答案
关键是模块是否具有默认导出,而是导入包含所有材质UI组件的模块( material-ui
模块)而不是只包含 RaisedButton
组件的模块( material-ui / RaisedButton
模块)。
The key thing is not whether the module has a default export or not, but the fact that you import a module that includes all the Material UI Components (the material-ui
module) instead of the module that includes only the RaisedButton
component (the material-ui/RaisedButton
module).
绝对清楚:我们应该使用仅包含单个组件的模块,即 material-ui / RaisedButton
。
To be absolutely clear: We should be using the module that only includes a single component, i.e. material-ui/RaisedButton
.
这篇关于为什么导出/导入默认ES模块属性比命名模块属性更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!