Closed metametadata closed 7 years ago
I'm going to close this. If I understand everything correctly, the root problem is that material-ui
is not written in the Google Closure "way".
cljs-react-material-ui
depends on cljsjs/material-ui which in turn includes material-ui via :foreign-libs
mechanism. And foreign libs are not a subject to DCE.
yes, dead code elimination doesn't work for any cljsjs library, one you require it in a namespace you buy a whole package
I have a sample project which uses
Reagent
. Merely including thecljs-react-material-ui
dependency adds about 500kb to the compiled .js file (using advanced compilation mode; before gzipping). It's not really expected because no code from the library is actually used yet in the project's codebase (well, except the React which is "included" intocljs-react-material-ui
?).This is how I add the dependency:
before:
after:
If the Closure compiler can't eliminate the dead code in this primitive case than I can also conclude that it will not be able to optimise the code when I require and really use a few Material UI components from the library. Is this correct? Can this be somehow fixed to make compiler eliminate code for MaterialUI components not used in my codebase?
After some experiments it looks like dead code elimination only kicks in if there are no mentions of React in my codebase.
Related stuff
Can these issues be somehow related to the described problem?