Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Clarify when bundle size optimization is needed #36823

Merged

Conversation

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation performance labels Apr 9, 2023
@@ -4,23 +4,25 @@

## Bundle size matters

The bundle size of MUI is taken very seriously. Size snapshots are taken
MUI takes the bundle size very seriously. Size snapshots are taken
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUI isn't a product

MUI exposes its full API on the top-level `@mui` imports.
If you're using ES6 modules and a bundler that supports tree-shaking ([`webpack` >= 2.x](https://webpack.js.org/guides/tree-shaking/), [`parcel` with a flag](https://en.parceljs.org/cli.html#enable-experimental-scope-hoisting/tree-shaking-support)) you can safely use named imports and still get an optimized bundle size automatically:
If you're using ES6 modules and a bundler that supports tree-shaking ([`webpack` >= 2.x](https://webpack.js.org/guides/tree-shaking/), [`parcel` with a flag](https://en.parceljs.org/cli.html#enable-experimental-scope-hoisting/tree-shaking-support)) you can safely use named imports and still get an optimized bundle size automatically in **production**:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so often overlooked.


```js
import { Button, TextField } from '@mui/material';
```

⚠️ The following instructions are only needed if you want to optimize your development startup times or if you are using an older bundler
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the convention for warnings.

Comment on lines +192 to 194
+ "start": "react-app-rewired start",
+ "build": "react-app-rewired build",
+ "test": "react-app-rewired test",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the correct git diff output.

@@ -210,10 +212,20 @@ It will perform the following diffs:
## Available bundles
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got so confused about this section, it should be clearer now.

@mui-bot
Copy link

mui-bot commented Apr 9, 2023

Netlify deploy preview

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 97787ea

@oliviertassinari oliviertassinari merged commit b1c6ad3 into mui:master Apr 23, 2023
5 checks passed
@oliviertassinari oliviertassinari deleted the bundle-size-improve-docs branch April 23, 2023 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants