Reputation: 2302
Using gulp, browserify & babelify, exporting/import classes worked fine until I tried to import the same class under a different name:
// Acme/DefaultInit.js
export default class DefaultInit {
constructor() {
console.log('hello');
}
}
// App/Init.js
import * as B from "../Acme/DefaultInit";
class Init extends B.DefaultInit {
constructor() {
super();
console.log('how are you?');
}
}
So when I run the gulp built script, the error is:
TypeError: Super expression must either be null or a function, not undefined
coming from the babel generated code
if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); }
What I'm doing wrong there ? Note that are no jslint errors
Upvotes: 1
Views: 2348
Reputation: 86
You're exporting DefaultInit
as a default so it'll actually be available from B.default
not B.DefaultInit
.
If you want to be able to do B.DefaultInit
drop the default
from before class DefaultInit
or alternatively replace import * as B
to import DefaultInit
.
Upvotes: 4