webpack-configurator icon indicating copy to clipboard operation
webpack-configurator copied to clipboard

TypeError: Class constructor ____ cannot be invoked without 'new'

Open yofreke opened this issue 8 years ago • 1 comments

Cannot specify plugins that are written with strict mode classes:

'use strict';
class MyPlugin {
  constructor () {}
  apply (compiler) {}
}
module.exports = MyPlugin;
/project/node_modules/webpack-configurator/lib/resolve/plugin.js:8
            return plugin.klass.apply(this, args);
                                ^

TypeError: Class constructor MyPlugin cannot be invoked without 'new'
    at MyPlugin.F (/project/node_modules/webpack-configurator/lib/resolve/plugin.js:8:33)
    at /project/node_modules/webpack-configurator/lib/resolve/plugin.js:13:16
    at module.exports (/project/node_modules/webpack-configurator/lib/resolve/plugin.js:14:8)
    at Config.resolve (/project/node_modules/webpack-configurator/index.js:180:22)
    at resolveConfigurator (/project/node_modules/webpack-multi-configurator/lib/definition-collection.js:227:27)
    at Array.map (native)
    at resolve (/project/node_modules/webpack-multi-configurator/lib/definition-collection.js:171:8)
    at Array.map (native)
    at Object.resolve (/project/node_modules/webpack-multi-configurator/index.js:98:38)
    at getWebpackConfig (/project/node_modules/jsio-webpack/src/builder.js:99:40)

yofreke avatar Oct 28 '16 21:10 yofreke

I was able to get around this by passing a function that returns a new instance of the Plugin instead of a constructor. i.e. config.plugin('plugin', () => new Plugin())

jayalfredprufrock avatar Nov 17 '17 03:11 jayalfredprufrock