-
Notifications
You must be signed in to change notification settings - Fork 67
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
Reduce dist size by 500 KB - reinstate browserslist, removing transforms for ancient browsers #3284
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @bradenmacdonald! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
✅ Deploy Preview for paragon-openedx ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3284 +/- ##
=======================================
Coverage 93.31% 93.31%
=======================================
Files 249 249
Lines 4441 4441
Branches 1014 1014
=======================================
Hits 4144 4144
Misses 294 294
Partials 3 3 ☔ View full report in Codecov by Sentry. |
After discussing in Paragon working group today we decided it likely makes the most sense to bring back the https://github.com/openedx/browserslist-config/ dependency and update that repo to follow browserslist best practices. That repo is currently set to past 2 major versions to match what was communicated on the edx.org support page, but it absolutely makes sense to increase the coverage to follow best practices. This will ensure we have the same level of support throughout all applications instead of just in Paragon. |
Ah, I wasn't aware that it had been removed at some point: #2501 That issue says
But this is only true if we distribute Paragon in a "buildless" manner, as .tsx/.jsx source files. As far as I know, none of our MFEs consume Paragon in that way. Since we do have an It would also be reasonable to distribute Paragon in the most modern form possible, and rely on MFE bunders (webpack+babel) to apply compatibility transforms/shims later where needed. But distributing it in the most compatible form (supporting ancient browsers) forces all the compatibility shims into each and every file, and as far as I know they can't get removed by later steps of the bundling process (in MFEs).
Sounds like a good plan! Do you want me to update this PR to add that dependency? |
That would be wonderful! Just adding back the dependency won't quite cover everything though, so a PR to https://github.com/openedx/browserslist-config updating the exports to use browserslist defaults would be great too! |
Description
Currently, Paragon is built using Babel's
preset-env
but without specifying anytargets
nor.browserslistrc
config file. This has the unfortunate effect that:So if you look at any of the files in
dist/
, you'll see that they are being transformed in an extremely inefficient way in order to support pre-ES5 browsers (that are more than a decade old!).In this PR, I am proposing we change the build to use the recommended
targets: defaults
option. This small change to the config results in a big 500KB savings to the transformed files indist
whennpm run build
is run:Before: 2,919,906 bytes (4.5 MB on disk) for 740 items
After: 2,401,170 bytes (4.1 MB on disk) for 740 items
I have also removed
@babel/plugin-proposal-class-properties
and@babel/plugin-proposal-object-rest-spread
because they're both deprecated (click their links for details), and the replacements are now included inpreset-env
so don't need to be separately installed.See also #3283 which makes a similar change for the icons.
What about compatibility?
This is now using the browserslist
defaults
query which is equivalent to> 0.5%, last 2 versions, Firefox ESR, not dead
. This is considered best practice. We could change it to@edx/browserslist-config
but as far as I can tell that's actually less compatible than the browserslist defaults (because it explicitly specifies only the few browsers supported by Open edX, whereas the browserslist defaults includes old browsers if they have enough marketshare). As an example, they advise "Don’t remove browsers just because you don’t know them. Opera Mini has 100 million users in Africa and it is more popular in the global market than Microsoft Edge. Chinese QQ Browsers has more market share than Firefox and desktop Safari combined." but Open edX browserslist config has removed those browsers.Example
Here is a typical diff showing the simplification that results in the build. This is
dist/Alert/index.js
.Deploy Preview
https://deploy-preview-3284--paragon-openedx.netlify.app
No changes should be discernable.
Merge Checklist
example
app?Post-merge Checklist