speed up build by fixing mui imports #189
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You're supposed to import MUI components individually, but I know this is had to remember, it's ugly, and hard to enforce:
See: https://mui.com/guides/minimizing-bundle-size/
The next.js maintainers believe this is part of why dev can take so long: vercel/next.js#29559. THey suggest using a special babel plugin, however that means you can't use the SWC compiler (written in Rust and much faster). So I found someone created a similar plugin and implemented that instead. Seems to be working, although the final build size has not changed, I Noticed that mentions of "@mui/icons-material" went from almost 10,000 to about 150 in the '.next/trace' file.
Another alternative is to use babel compiler with this config: https://mui.com/guides/minimizing-bundle-size/#option-2. I haven't tried it yet, but we'd be have do swap the Rust compiler (SWC) with babel, which is slower.