Bundle some ui dependencies separately to limit the build size of ui.js #5547
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.
This PR has the following change on our builds:
ui.js
ui.js
to decrease by almost a megabyteThe smaller build size is needed at this time in order for us to pass the file size requirement of the mozilla linter, which we now run every build against with circle ci (e.g. https://circleci.com/gh/MetaMask/metamask-extension/64220?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)
This was motivated by work I am doing on a feature branch which failed that step of the build.
The react and material-ui libraries here chosen for inclusion in a separate bundle were chosen because they:
Alternatively, we could build all front-end dependencies separately. That may, however, move us further from an ideal direction. The current PR meets an immediate need, as the file size failure of the mozilla linter is blocking current feature work. In the future, an more useful, generalizable and powerful approach would be to create separate bundles for separate parts of the app.
To help you understand the implementation. Browserify's
.require()
call is used to put a list of dependencies into its own bundle, and the.external()
call is used to keep a dependency out of a bundle and instead ensure that the bundle accesses the dependency from an external file. See https://github.com/browserify/browserify#multiple-bundlesFinally, I'll note some improvements we can make in the future:
*.html
files