Is it possible to create a dynamic class without preloading it? I would like to avoid preloading the class, since I'm dynamically importing it. Below is a code example that illustrates what I'm trying to achieve:
import(namespace).then((DynamicClass) => {
var classInstance = new DynamicClass();
}
This currently results in: (node:962) UnhandledPromiseRejectionWarning: TypeError: dynamicClass is not a constructor
When I console.log the DynamicClass, it shows:
{ default: [Function: DynamicClass] }
The class is defined like this:
namespace/index.js
class DynamicClass extends BaseClass {
//...
}
module.exports = DynamicClass;
dynamicClass.defaultmight be a constructor