Skip to content

[docs] Update minimizing-bundle-size.md #7169

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

Merged
merged 3 commits into from
Jun 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/src/pages/guides/minimizing-bundle-size.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Minimizing Bundle Size

For convenience, Material-UI exposes its full API on the top-level `material-ui` import.
However, this causes the entire library and its dependencies to be included in client bundles that include code that imports from the top-level bundle.
This will work fine if you have tree shaking working.

However, **in case tree shaking is not supported**, this causes the entire library and its dependencies to be included in client bundles that include code that imports from the top-level bundle.

You have couple of options to overcome this situation:

##### Option #1

You can import directly from `material-ui/` to avoid pulling in unused modules. For instance, instead of:

Expand All @@ -17,3 +23,9 @@ import TextField from 'material-ui/TextField'
```

The public API available in this manner is defined as the set of imports available from the top-level `material-ui` module. Anything not available through the top-level `material-ui` module is a **private API**, and is subject to change without notice.

##### Option #2

Another option to keep using the shorten import and still have the size of the bundle optimized would be to use [babel-plugin-material-ui](https://github.com/umidbekkarimov/babel-plugin-material-ui).

**Important note**: Both of the options **should be temporary** until you'll add tree shaking capabilities to your project.