This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
perf: use Object.assign
in @babel/plugin-proposal-object-rest-spread
#1895
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.
Thanks to Mario Baricevic for pointing to this.
🐢 Issue
We use
@babel-preset-env
to transform our code.According to
.browserslistrc
it will compile our code to be used in IE11, there are no support forObject.assign()
or object spread and it means that Babel helper will be used. However, we have already requiredObject.assign()
polyfill and it means that we can use it instead of Babel helper.Example input
Example output before
@babel/runtime/helpers/esm/objectSpread.js contains own implementation which is definitely slower.
Example output with
{ loose: true, useBuiltIns: true }
🏁 Measures
cross-env PERF=true gulp perf --filter *Chat.perf.tsx --times=100
I run the command above 4 times to test changes. During each sample run perf example was run 100 times.
Performance win is around 13%, see results below.
Before
After