Why is exporting/importing default ES module properties faster than names module properties?

I'm reading the Material UI documentation, and it states:

Notice that in the above example, we used: import RaisedButton from 'material-ui/RaisedButton'; instead of import {RaisedButton} from 'material-ui'; This will make your build process faster and your build output smaller.

I cannot find any justification for why the use of default exports makes the build process faster or build output smaller.

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.

Answers:

Answer

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).

To be absolutely clear: We should be using the module that only includes a single component, i.e. material-ui/RaisedButton.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.