Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yofreke opened this issue Oct 28, 2016 · 1 comment
Open

Comments

@yofreke
Copy link

yofreke commented Oct 28, 2016

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)
@jayalfredprufrock
Copy link

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants