Increased bundle size after upgrading past 7.6
See original GitHub issuev7 Regression
Potential Commit/PR that introduced the regression https://github.com/babel/babel/pull/10161
Description
When we recently upgraded from 7.5
to 7.8
we experienced a bundle size increase from ~3,4 MB
to 3.5 MB
minified (+90 KB
difference)
When we checked the bundle diff, we found that a function _getRequireWildcardCache
is being re-defined for every module in our application and adds quite a bunch of code in total.
Searching for the function, we found that it’s a new feature in babel 7.6
. Here’s a blog post where @ifsnow , who built this feature explains it nicely: https://www.notion.so/Improving-Babel-Import-performance-makes-React-Native-faster-4ab20915a599481ab8fbb4993db38709 (thanks for the explanation by the way)
But what we find now is that besides the performance improvement we’re hoping to get, we’re seeing this regression in bundle size.
Is that to be expected? Is it possible to opt-out of this optimization?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
If you are also using
preset-env
, I suggest using it’suseBuiltIns: usage
option rather thanplugin-transform-runtime
’scorejs
. This is becausepreset-env
only includes polyfills for your target environments, whiletransform-runtime
polyfills everything.If you are already using
@babel/plugin-transform-runtime
, this is probably what is happening: the helper has been updated, so Babel must inline it to ensure that you are using the new version (just in case your@babel/runtime
is old). You can prevent this by passing a"version": "^7.6.0"
(or whatever you are using) to tell “Hey Babel, I’m already using a version which includes the new feature. You don’t need to inline it!”.