Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 483
Charles Stover Avatar asked Jan 03 '23 21:01

Charles Stover


1 Answers

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.

like image 67
Lars Gyrup Brink Nielsen Avatar answered Jan 05 '23 16:01

Lars Gyrup Brink Nielsen