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] Reduce bundle size #16046

Merged
merged 7 commits into from
Jul 22, 2019
Merged

[docs] Reduce bundle size #16046

merged 7 commits into from
Jul 22, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Jun 4, 2019

Let next decide on the used module format.

Replaces next-transpile-modules with a custom config. next-transpile-modules (despite its name) is not concerned with transpiling node_modules but modules of a monorepo.

Using babel-plugin-module-resolver to alias @material-ui packages of this repository in 3rd party librarys (notistack, material-table etc). No need to apply all presets/plugins.

Followup:

  • Cleanup next.config (separate concerns into plugins and use with-plugins composer)

@eps1lon eps1lon added docs Improvements or additions to the documentation performance labels Jun 4, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Jun 4, 2019

Details of bundle changes.

Comparing: a3ae056...5503947

bundle parsed diff gzip diff prev parsed current parsed prev gzip current gzip
@material-ui/core 0.00% 0.00% 325,780 325,780 89,850 89,850
@material-ui/core/Paper 0.00% 0.00% 67,971 67,971 20,322 20,322
@material-ui/core/Paper.esm 0.00% 0.00% 61,770 61,770 19,160 19,160
@material-ui/core/Popper 0.00% 0.00% 28,896 28,896 10,401 10,401
@material-ui/core/Textarea 0.00% 0.00% 5,534 5,534 2,370 2,370
@material-ui/core/TrapFocus 0.00% 0.00% 3,808 3,808 1,602 1,602
@material-ui/core/styles/createMuiTheme 0.00% 0.00% 16,156 16,156 5,813 5,813
@material-ui/core/useMediaQuery 0.00% 0.00% 3,098 3,098 1,314 1,314
@material-ui/lab 0.00% 0.00% 141,684 141,684 43,585 43,585
@material-ui/styles 0.00% 0.00% 51,387 51,387 15,306 15,306
@material-ui/system 0.00% 0.00% 15,574 15,574 4,439 4,439
Button 0.00% 0.00% 79,776 79,776 24,359 24,359
Modal 0.00% 0.00% 14,613 14,613 5,227 5,227
Portal 0.00% 0.00% 3,471 3,471 1,572 1,572
Rating 0.00% 0.00% 70,334 70,334 22,067 22,067
Slider 0.00% 0.00% 75,105 75,105 23,310 23,310
colorManipulator 0.00% 0.00% 3,904 3,904 1,543 1,543
docs.landing -5.51% -2.82% 54,246 51,259 13,930 13,537
docs.main -9.25% -6.03% 639,411 580,256 202,521 190,313
packages/material-ui/build/umd/material-ui.production.min.js 0.00% 0.00% 299,949 299,949 86,208 86,208
docs: / -5.15% 0.00% 58,200 55,200 -1 -1
docs: /_app -0.75% 0.00% 134,000 133,000 -1 -1
docs: /_error 0.00% 0.00% 2,110 2,110 -1 -1
docs: /blog/2019-developer-survey-results 0.00% 0.00% 13,600 13,600 -1 -1
docs: /blog/april-2019-update -1.70% 0.00% 4,700 4,620 -1 -1
docs: /blog/june-2019-update -3.51% 0.00% 2,280 2,200 -1 -1
docs: /blog/march-2019-update -2.45% 0.00% 3,260 3,180 -1 -1
docs: /blog/material-ui-v4-is-out -0.44% 0.00% 22,600 22,500 -1 -1
docs: /blog/may-2019-update -2.83% 0.00% 2,830 2,750 -1 -1
docs: /components/about-the-lab -1.24% 0.00% 6,450 6,370 -1 -1
docs: /components/app-bar -9.59% 0.00% 146,000 132,000 -1 -1
docs: /components/autocomplete -2.25% 0.00% 311,000 304,000 -1 -1
docs: /components/avatars -1.89% 0.00% 26,400 25,900 -1 -1
docs: /components/badges -11.58% 0.00% 66,500 58,800 -1 -1
docs: /components/bottom-navigation -6.86% 0.00% 27,700 25,800 -1 -1
docs: /components/box 0.00% 0.00% 32,900 32,900 -1 -1
docs: /components/breadcrumbs -9.91% 0.00% 109,000 98,200 -1 -1
docs: /components/buttons -7.54% 0.00% 252,000 233,000 -1 -1
docs: /components/cards -5.85% 0.00% 76,900 72,400 -1 -1
docs: /components/checkboxes -6.47% 0.00% 69,500 65,000 -1 -1
docs: /components/chips -6.61% 0.00% 121,000 113,000 -1 -1
docs: /components/click-away-listener 0.00% 0.00% 13,300 13,300 -1 -1
docs: /components/container -2.34% 0.00% 12,800 12,500 -1 -1
docs: /components/css-baseline -0.52% 0.00% 19,300 19,200 -1 -1
docs: /components/dialogs -5.63% 0.00% 231,000 218,000 -1 -1
docs: /components/dividers -6.83% 0.00% 54,200 50,500 -1 -1
docs: /components/drawers -3.43% 0.00% 233,000 225,000 -1 -1
docs: /components/expansion-panels -5.98% 0.00% 88,600 83,300 -1 -1
docs: /components/grid -5.59% 0.00% 161,000 152,000 -1 -1
docs: /components/grid-list -3.73% 0.00% 59,000 56,800 -1 -1
docs: /components/hidden -3.53% 0.00% 56,700 54,700 -1 -1
docs: /components/icons -2.68% 0.00% 149,000 145,000 -1 -1
docs: /components/links -10.41% 0.00% 58,600 52,500 -1 -1
docs: /components/lists -15.76% 0.00% 184,000 155,000 -1 -1
docs: /components/menus -3.29% 0.00% 91,200 88,200 -1 -1
docs: /components/modal 0.00% 0.00% 37,600 37,600 -1 -1
docs: /components/no-ssr -2.47% 0.00% 16,200 15,800 -1 -1
docs: /components/paper +0.11% 🔺 0.00% 9,500 9,510 -1 -1
docs: /components/pickers -50.91% 0.00% 383,000 188,000 -1 -1
docs: /components/popover -6.10% 0.00% 72,100 67,700 -1 -1
docs: /components/popper -7.50% 0.00% 120,000 111,000 -1 -1
docs: /components/portal -0.82% 0.00% 12,200 12,100 -1 -1
docs: /components/progress -1.92% 0.00% 104,000 102,000 -1 -1
docs: /components/radio-buttons -7.07% 0.00% 60,800 56,500 -1 -1
docs: /components/rating -15.85% 0.00% 42,900 36,100 -1 -1
docs: /components/selects -8.43% 0.00% 178,000 163,000 -1 -1
docs: /components/slider -3.35% 0.00% 80,600 77,900 -1 -1
docs: /components/snackbars +2.63% 🔺 0.00% 114,000 117,000 -1 -1
docs: /components/speed-dial -13.85% 0.00% 62,100 53,500 -1 -1
docs: /components/steppers -3.29% 0.00% 213,000 206,000 -1 -1
docs: /components/switches -5.41% 0.00% 75,800 71,700 -1 -1
docs: /components/tables -6.29% 0.00% 779,000 730,000 -1 -1
docs: /components/tabs -7.19% 0.00% 167,000 155,000 -1 -1
docs: /components/text-fields -3.29% 0.00% 304,000 294,000 -1 -1
docs: /components/textarea-autosize -3.90% 0.00% 5,890 5,660 -1 -1
docs: /components/toggle-button -8.79% 0.00% 23,900 21,800 -1 -1
docs: /components/tooltips -3.96% 0.00% 98,400 94,500 -1 -1
docs: /components/transfer-list -7.00% 0.00% 51,400 47,800 -1 -1
docs: /components/transitions -7.20% 0.00% 62,500 58,000 -1 -1
docs: /components/typography -0.77% 0.00% 38,800 38,500 -1 -1
docs: /components/use-media-query -0.54% 0.00% 55,100 54,800 -1 -1
docs: /customization/breakpoints -0.12% 0.00% 80,800 80,700 -1 -1
docs: /customization/color +0.51% 🔺 0.00% 97,200 97,700 -1 -1
docs: /customization/components -2.38% 0.00% 168,000 164,000 -1 -1
docs: /customization/default-theme -4.18% 0.00% 79,000 75,700 -1 -1
docs: /customization/density -17.70% 0.00% 22,600 18,600 -1 -1
docs: /customization/globals -1.49% 0.00% 20,100 19,800 -1 -1
docs: /customization/palette 0.00% 0.00% 57,500 57,500 -1 -1
docs: /customization/spacing -0.79% 0.00% 12,700 12,600 -1 -1
docs: /customization/themes -1.45% 0.00% 62,200 61,300 -1 -1
docs: /customization/typography -21.82% 0.00% 550,000 430,000 -1 -1
docs: /customization/z-index -0.82% 0.00% 9,810 9,730 -1 -1
docs: /discover-more/backers -1.17% 0.00% 6,860 6,780 -1 -1
docs: /discover-more/changelog -1.93% 0.00% 3,630 3,560 -1 -1
docs: /discover-more/community -1.45% 0.00% 5,520 5,440 -1 -1
docs: /discover-more/governance -1.16% 0.00% 6,880 6,800 -1 -1
docs: /discover-more/languages -14.41% 0.00% 11,800 10,100 -1 -1
docs: /discover-more/related-projects -0.53% 0.00% 18,900 18,800 -1 -1
docs: /discover-more/roadmap -1.20% 0.00% 6,690 6,610 -1 -1
docs: /discover-more/showcase -4.45% 0.00% 74,100 70,800 -1 -1
docs: /discover-more/team -4.39% 0.00% 22,800 21,800 -1 -1
docs: /discover-more/vision 0.00% 0.00% 19,100 19,100 -1 -1
docs: /getting-started/example-projects 0.00% 0.00% 24,200 24,200 -1 -1
docs: /getting-started/faq 0.00% 0.00% 154,000 154,000 -1 -1
docs: /getting-started/installation -0.32% 0.00% 31,400 31,300 -1 -1
docs: /getting-started/learn -0.29% 0.00% 34,600 34,500 -1 -1
docs: /getting-started/page-layout-examples -5.88% 0.00% 30,600 28,800 -1 -1
docs: /getting-started/page-layout-examples/album -19.26% 0.00% 12,200 9,850 -1 -1
docs: /getting-started/page-layout-examples/blog -8.07% 0.00% 34,700 31,900 -1 -1
docs: /getting-started/page-layout-examples/checkout -17.47% 0.00% 56,100 46,300 -1 -1
docs: /getting-started/page-layout-examples/dashboard -24.42% 0.00% 520,000 393,000 -1 -1
docs: /getting-started/page-layout-examples/pricing -25.91% 0.00% 27,400 20,300 -1 -1
docs: /getting-started/page-layout-examples/sign-in -20.81% 0.00% 54,300 43,000 -1 -1
docs: /getting-started/page-layout-examples/sign-in-side -20.88% 0.00% 54,600 43,200 -1 -1
docs: /getting-started/page-layout-examples/sign-up -20.80% 0.00% 54,800 43,400 -1 -1
docs: /getting-started/page-layout-examples/sticky-footer -17.39% 0.00% 2,530 2,090 -1 -1
docs: /getting-started/supported-components -0.14% 0.00% 73,900 73,800 -1 -1
docs: /getting-started/supported-platforms -0.42% 0.00% 23,900 23,800 -1 -1
docs: /getting-started/usage -0.62% 0.00% 32,200 32,000 -1 -1
docs: /guides/api 0.00% 0.00% 62,100 62,100 -1 -1
docs: /guides/composition -6.19% 0.00% 113,000 106,000 -1 -1
docs: /guides/flow -1.40% 0.00% 5,710 5,630 -1 -1
docs: /guides/interoperability -2.63% 0.00% 190,000 185,000 -1 -1
docs: /guides/migration-v0x 0.00% 0.00% 52,300 52,300 -1 -1
docs: /guides/migration-v3 0.00% 0.00% 129,000 129,000 -1 -1
docs: /guides/minimizing-bundle-size -0.22% 0.00% 45,700 45,600 -1 -1
docs: /guides/responsive-ui -0.69% 0.00% 14,400 14,300 -1 -1
docs: /guides/right-to-left -7.80% 0.00% 50,000 46,100 -1 -1
docs: /guides/server-rendering -0.17% 0.00% 58,600 58,500 -1 -1
docs: /guides/testing 0.00% 0.00% 50,200 50,200 -1 -1
docs: /guides/typescript -0.13% 0.00% 79,200 79,100 -1 -1
docs: /performance/table-component -12.42% 0.00% 1,530 1,340 -1 -1
docs: /performance/table-emotion -7.01% 0.00% 27,100 25,200 -1 -1
docs: /performance/table-hook -11.80% 0.00% 1,610 1,420 -1 -1
docs: /performance/table-mui -24.52% 0.00% 8,320 6,280 -1 -1
docs: /performance/table-raw -13.28% 0.00% 1,280 1,110 -1 -1
docs: /performance/table-styled-components -5.26% 0.00% 45,600 43,200 -1 -1
docs: /premium-themes/instapaper -18.70% 0.00% 108,000 87,800 -1 -1
docs: /premium-themes/onepirate -14.43% 0.00% 58,900 50,400 -1 -1
docs: /premium-themes/onepirate/forgot-password -13.37% 0.00% 87,500 75,800 -1 -1
docs: /premium-themes/onepirate/privacy -13.48% 0.00% 80,100 69,300 -1 -1
docs: /premium-themes/onepirate/sign-in -13.41% 0.00% 88,000 76,200 -1 -1
docs: /premium-themes/onepirate/sign-up -13.38% 0.00% 88,200 76,400 -1 -1
docs: /premium-themes/onepirate/terms -10.58% 0.00% 103,000 92,100 -1 -1
docs: /premium-themes/paperbase -17.87% 0.00% 64,900 53,300 -1 -1
docs: /premium-themes/tweeper -18.63% 0.00% 117,000 95,200 -1 -1
docs: /styles/advanced -41.98% 0.00% 405,000 235,000 -1 -1
docs: /styles/api 0.00% 0.00% 126,000 126,000 -1 -1
docs: /styles/basics +0.34% 🔺 0.00% 89,000 89,300 -1 -1
docs: /system/api -0.13% 0.00% 77,800 77,700 -1 -1
docs: /system/basics -5.56% 0.00% 198,000 187,000 -1 -1
docs: /system/borders -13.10% 0.00% 43,500 37,800 -1 -1
docs: /system/display -8.66% 0.00% 63,500 58,000 -1 -1
docs: /system/flexbox -9.28% 0.00% 75,400 68,400 -1 -1
docs: /system/palette -15.85% 0.00% 32,800 27,600 -1 -1
docs: /system/positions -18.22% 0.00% 26,900 22,000 -1 -1
docs: /system/shadows -20.08% 0.00% 26,400 21,100 -1 -1
docs: /system/sizing -15.06% 0.00% 35,200 29,900 -1 -1
docs: /system/spacing -9.14% 0.00% 54,700 49,700 -1 -1
docs: /system/typography -11.22% 0.00% 50,800 45,100 -1 -1
docs: /versions -2.54% 0.00% 78,700 76,700 -1 -1

Generated by 🚫 dangerJS against 5503947

@eps1lon
Copy link
Member Author

eps1lon commented Jun 4, 2019

Something is off with the typescript compilation. I now realized that this means we bundle them both and also run both. It's probably best to revert this change and stick with yarn docs:typescript:formatted --watch.

@oliviertassinari
Copy link
Member

What do you mean by we run and bundle them both?

@eps1lon
Copy link
Member Author

eps1lon commented Jun 4, 2019

What do you mean by we run and bundle them both?

Don't know how describe this otherwise. The JS and the transpiled TS is bundled and evaluated. The variant used switches when the codevariant switches. Neither of which is useful. The JS version is equivalent at runtime.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 4, 2019

As long as we can, in development, edit the TypeScript demos and see the changes live (without any additional script running), I'm happy. I'm worried that requiring a running script will make the demo edition experience slower.
Do we have an idea of the cost of this current design? I mean, is this the biggest bottleneck? Would we win 50% of TTI by reverting?

@eps1lon
Copy link
Member Author

eps1lon commented Jun 4, 2019

Just wading through babel, webpack and next configs now. We can think about this later. If it requires too much configuration I'll revert. Having another script running in the background shouldn't be a problem. Plenty of popular repos require this (i.e. when testing production bundles).

@oliviertassinari
Copy link
Member

It seems that we will have to make a tradeoff. Here are the important dimensions I can think of:

  • The document edition time in development. The faster, the better the documentation can be (as we can save time when editing it, hence making more changes).
  • The document load time in production. The faster, the more trust people will have in our components.

@eps1lon
Copy link
Member Author

eps1lon commented Jun 4, 2019

Not sure what's happening currently. If I entry on pages with complementary projects I get Object() is not a function but when I navigate to it I get exports is not defined.

May very well be that our current dependency graph is not supported. Will try to get minimal example that highlights the graph and see when it breaks.

Build is passing because production is still using the old config.

@eps1lon eps1lon force-pushed the docs/better-chunk-esm branch from 3bb2e9f to fd3913c Compare June 11, 2019 13:25
@eps1lon
Copy link
Member Author

eps1lon commented Jun 11, 2019

I seem to be on the right track:

$ yarn docs:dev
# visit localhost:3000
# navigate to pickers demo
# works
# but land directly on localhost:3000/components/pickers and files inside node_modules requiring `@material-ui/*` files can't find the those modules.

@eps1lon
Copy link
Member Author

eps1lon commented Jul 20, 2019

Probably need to be more granular about externals. Works locally but I doubt we can increase the memory limit in CI.

@eps1lon eps1lon force-pushed the docs/better-chunk-esm branch from db36461 to 93b0231 Compare July 21, 2019 14:45
@eps1lon eps1lon marked this pull request as ready for review July 21, 2019 15:49
@eps1lon eps1lon requested a review from oliviertassinari July 21, 2019 15:50
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

:)

['next/babel', { 'preset-env': { modules: 'commonjs' } }],
'@zeit/next-typescript/babel',
],
presets: ['next/babel', '@zeit/next-typescript/babel'],
Copy link
Member

Choose a reason for hiding this comment

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

Would it be enough?

Suggested change
presets: ['next/babel', '@zeit/next-typescript/babel'],
presets: ['next/babel'],

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 think so. That should've been removed when upgrading to next 9

@eps1lon eps1lon merged commit 95522aa into mui:master Jul 22, 2019
@eps1lon eps1lon deleted the docs/better-chunk-esm branch July 22, 2019 10:58
eps1lon added a commit to eps1lon/material-ui that referenced this pull request Jul 22, 2019
* [docs] Use ES6 modules for client builds

* Use blocklist for externals instead of allowlist

* Use babel for aliases

Very high memory consumption when inlining  @material-ui/ packages

* Remove next-transpile-modules

* poke codecov

* poke codecov

* Remove redundant @zeit/next-typescript/babel
@merceyz merceyz mentioned this pull request Aug 3, 2019
1 task
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.

4 participants