So I'm having issues with sub-classes extending a super class in Webpack.
My super class: core/Main.js
class Main {
constructor () {
console.log('Main Class Initialized');
}
}
module.exports = Main;
Sub-class: app/Launch.js
var Main = require('core/Main.js');
class Launch extends Main {
constructor () {
console.log('Before Super')
super();
console.log('Launch Class Initialized')
}
}
If I console.log(Main)
inside of the app/Launch.js file it logs Main and 'Before Super' also gets logged, but calling super()
causes it to break and I have no idea why.
How to achieve inheritance in ES6 with “webpack module bundler”? didn't help. I tried swapping out module.exports
for export class Main {}
and require('core/Main.js')
for import {Main} from 'core/Main.js'
, but it didn't work. Using webpack 1.14.0.
Got it. I copied
Main.js
intoapp/
and required that. Works fine now, don't know why that made a difference though.