Skip to content

Conversation

@cpirich
Copy link
Contributor

@cpirich cpirich commented Nov 22, 2019

  • Shrink our external package main.js (used within Code Studio) by 34%: from 9885072 bytes to 6546734 bytes by keeping four packages out of our bundle and labeling them as externals: lodash, radium, react, and react-dom. These are now listed as peerDependencies by our package, indicating that we expect anyone linking our package to also link those packages alongside ml-activities
  • Stop generating production (main.js) when running yarn start - we only do this when running yarn build now
  • Removed some unreferenced packages from package.json: jquery-ui-touch-punch, jquery-ui, react-bootstrap, react-color
  • Added webpack-bundle-analyzer as a devDependency so we can easily invoke it if we want to understand our bundle (and generate pretty pictures like the ones below)

Before:
Screen Shot 2019-11-22 at 3 08 23 PM

After:
Screen Shot 2019-11-22 at 3 10 17 PM

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for tackling this @cpirich !

If you want to optimize further and run out of things that are shared with existing code studio bundles, then another option is to split some of the larger dependencies into a separate file so they can be loaded in parallel. Here is an example of how we did this on code studio pages: code-dot-org/code-dot-org#30374

"lodash": "^4.17.5",
"radium": "^0.25.2",
"react": "~15.4.0",
"react-dom": "~15.4.0"
Copy link
Member

Choose a reason for hiding this comment

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

Heads up @jmkulwik that if you bump the react version to 15.6 in our main repo, that you may need to bump these too.

@cpirich cpirich merged commit 3bf4814 into master Nov 23, 2019
@cpirich cpirich deleted the cpirich/shrink-main-webpack-by-using-externals branch November 23, 2019 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants