0
votes
  new SuppressChunksPlugin([
    ^

TypeError: SuppressChunksPlugin is not a constructor at Object. (/Users/rohit/WebstormProjects/myProjectStructure/webpack.config.js:80:9) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at requireConfig (/usr/local/lib/node_modules/webpack/bin/convert-argv.js:97:18) at /usr/local/lib/node_modules/webpack/bin/convert-argv.js:104:17

Below is the web config files.

var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin');



module.exports = {
    context: path.resolve(__dirname, './src'),
  entry: {
        blitz: './blitz.js',


  },
  output: {
    path: path.resolve(__dirname, './dist/assets'),
    filename: '[name].bundle.js'

    },


    module: {


       rules: [
            {
            test: /\.less$/,
            use: ExtractTextPlugin.extract({
                // use style-loader in development
                fallback: 'style-loader',
                use: 'css-loader?minimize!less-loader'

              })
            },

           {
               test: /\.css$/,
               use: ExtractTextPlugin.extract({
                   fallback: 'style-loader',
                   use:'css-loader?minimize'

               })
           }
       ]
    },
    plugins:[
        new ExtractTextPlugin('[name].css'),
        new SuppressChunksPlugin([
            {name: 'blitz', match: /\.js$/},

        ])
    ]
};
1
Can you post your webpack.config.js file?83N
Hi, have updated with the web config file as well.Rohit Gowda

1 Answers

4
votes

The suppress-chunks-webpack-plugin uses ES modules and only has a default export (see also the transpiled source unpkg - suppress-chunks-webpack-plugin).

To use it with Node's require you need to access the default property.

var SuppressChunksPlugin = require('suppress-chunks-webpack-plugin').default;