If I declare class using es6 class keyword:
class Foo {
constructor(foo, bar) {}
}
module.exports = Foo;
And I try to load it using wire:
wire({
"foo": {
"module": "Foo",
"args": ["monty", "python"],
},
});
I get an error:
TypeError: Class constructors cannot be invoked without 'new'
at BrowserConnectionFactory ()
at instantiate (.../node_modules/wire/lib/instantiate.js:37:20)
at createInstance (.../node_modules/wire/lib/plugin/basePlugin.js:250:7)
Wire (actually when) is trying to do Foo.apply(new_foo, args), which is not allowed in es6. Solution would be using new spread operator - new Foo(...args) , but that is not backwards-compatible.
PR #180 has possible workaround with named constructors which can be called with "apply".
If I declare class using es6 class keyword:
And I try to load it using wire:
I get an error:
Wire (actually when) is trying to do
Foo.apply(new_foo, args), which is not allowed in es6. Solution would be using new spread operator -new Foo(...args), but that is not backwards-compatible.PR #180 has possible workaround with named constructors which can be called with "apply".