You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a sample project which uses Reagent. Merely including the cljs-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" into cljs-react-material-ui?).
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?
Cljsjs/material-ui required by cljs-react-material-ui increases output size by about 1.4MB.
700KB of that is necessary, other 700KB is caused by bug in cljsjs/material-ui which causes the code be included twice.
- To save 700KB, fix cljsjs/material-ui
- To save more, stop using material-ui, or
- Wait for Closure and ClojureScript to support npm/commonjs module processing which would allow running dead code elimination on material-ui code
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.
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?
The text was updated successfully, but these errors were encountered: