最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reduce babel-polyfill size (150 KB minified)? - Stack Overflow

programmeradmin0浏览0评论

I just setup new webpack 4 project and in my main js file imported babel-polyfill

import 'babel-polyfill';

And after webpack production build i analized my bandle with source-map-explorer i see such picture

So babel-polyfill (core-js) took 150 Kb which is too much IMO.

Any thoughts how can i reduce size ? I don't want to include any specific polyfills (there should be some tree-shaking, so not used code should be deleted ?).

I use this boilerplate:

I just setup new webpack 4 project and in my main js file imported babel-polyfill

import 'babel-polyfill';

And after webpack production build i analized my bandle with source-map-explorer i see such picture

So babel-polyfill (core-js) took 150 Kb which is too much IMO.

Any thoughts how can i reduce size ? I don't want to include any specific polyfills (there should be some tree-shaking, so not used code should be deleted ?).

I use this boilerplate: https://github./flexdinesh/react-redux-boilerplate/tree/master/config

Share Improve this question edited Apr 29, 2018 at 11:02 Vololodymyr asked Apr 29, 2018 at 10:44 VololodymyrVololodymyr 2,2986 gold badges31 silver badges53 bronze badges 2
  • @JaromandaX, none. But according to ments from github it should be ~60-80 Kb minified. And in my case i see x2 size and this is strange. Don't you think ? – Vololodymyr Commented Apr 29, 2018 at 12:55
  • Oh, I didn't know that - sorry – Jaromanda X Commented Apr 29, 2018 at 22:46
Add a ment  | 

1 Answer 1

Reset to default 5 +50

The size of 150kb seems reasonable to me because you're importing all polyfills. Therefore the tree-shaking feature of webpack4 will not remove any unused code because everything is used.

I might assume the sources claiming the size for the whole bundle should be ~60-80kb meant the size after minification + pression.

Did you read the instructions of how to use the @babel/polyfill library correctly? It remends the usage of @babel/preset-env to import only the polyfills you need for your production target. This will probably greatly reduce the size of your bundle.

发布评论

评论列表(0)

  1. 暂无评论