Why is the dependency repeated many times in the Webpack artifact?

I have an assembly of web packages with multiple inputs, and I'm working on optimizing the size of the artifact for production. webpack-bundle-analyzerThe following picture appeared:

enter image description here

Obviously, AtlasKit dependencies make up a huge chunk of overall artifact size. In particular, I see that styled-components.es.jsrepeated many times. Moreover, the same dependency is also present in vendor.js, which in itself is used for all other packages.

- , styled-components.es.js vendor.js? -, , styled-components.es.js vendor.js?

, AtlasKit node_modules, . dist ? , , styled-components.es.js vendor.js?

enter image description here

webpack IgnorePlugin ( moment.js), .

. !

+4
1

, : webpack.CommonsChunkPlugin.

minChunks, :

minChunks: number | Infinity | function (module, count) โ†’ boolean,   // , , .   // 2 .   // Infinity commons, .   // function, . ( )

Webpack:

new webpack.optimize.CommonsChunkPlugin({
  children: true,
  async: true,
  minChunks: 3
})

.

, , , samccone/bundle-buddy Webpack.

CommonsChunkPlugin, Webpack, .

+1

Source: https://habr.com/ru/post/1685708/


All Articles