Can Webpack hoist extended classes?
I am using Webpack and Babel to bundle and transpile a bunch of classes, each from a separate file.
My Webpack entry file is an index.js file containing import statements of every class ordered by name,
index.js:
import classA from './a';
import classB from './b';
import classC from './c';
import classD from './d';
...
a.js:
export class classA extends classD {
constructor(...) {
super(...);
}
}
My problem is that the classes gets imported ordered by name, so classD
will be declared after classA
and will break the program because of javascript hoisting/initialization rules.
So my question is if there is a way for Webpack to sort the classes and put them in the necessary order? Or is my only choice to sort them manually?