commonsChunkPlugins async options Invalid

Do you want to request a feature or report a bug?
bug

What is the current behavior?

  • I am using webpack2.4.0, in my webpack.config.js use plugin webpack.optimize.COmmonsChunkPlugin options async and minChunks
  • like
new webpack.optimize.CommonsChunkPlugin({
  async:"used-twice",
  minChunks:(module,count)=> ( count >=2 )
})
  • That’s fine, in my project I have a generated file used-twice.js
    If the current behavior is a bug, please provide the steps to reproduce.
  • but I today upgrade webpack@.2.4 => webpack@3.0.0 found webpack.optimize.COmmonsChunkPlugin options async invalid
  • can’t build file used-twice.js
  • after I use yarn add other webpack versions like v.2.5 v.2.6.0 v.3.0.0 All invalid 🙁
  • but webpack@2.4.0 succeed
  • I don’t know how to solve it ! Please help me, Thanks.
  • English is so tired with Google

What is the expected behavior?

  • build a common chunk file used-twice.js

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

  • window
  • node 8.1.0
  • webpack 2.6.0

Author: Fantashit

1 thought on “commonsChunkPlugins async options Invalid

  1. I’ve been using "webpack": "^2.5.1" until now and this below used to work.

      new webpack.optimize.CommonsChunkPlugin({
        names: ['vendor'],
        minChunks: function(module) {
          return module.context && module.context.indexOf('node_modules') !== -1;
        },
      }),
    
      new webpack.optimize.CommonsChunkPlugin({
        name: 'manifest', //But since there are no more common modules between them we end up with just the runtime code included in the manifest file
      }),
    
    

    Upgrading to webpack 3.0.0 started throwing error Uncaught TypeError: Cannot read property 'call' of undefined in the browser in manifest.js.

    Changing it to below worked for me

    
      new webpack.optimize.CommonsChunkPlugin({
        names: ['vendor', 'manifest'],
      }),
    

    @lijinke666
    I’m not sure how will it work in your way. And also, I would be waiting for the bug to get fixed as above 2 code aren’t exactly same.

Comments are closed.