Is ES2015+, how can I dynamically import a module?
E.g. instead of...
import {SomeClass} from 'lib/whatever/some-class';
I don't know the path at runtime, so I want to I have the path stored in a variable, and I want to import a specific thing from that module:
function doDynamicStuff(path) {
let importedThing = ...; //import * as importedThing from path;
let thingIReallyWant = importedThing.someExportedVariable;
...
}
I'm not sure what syntax to use, or if it's possible to do this at all. I tried using let importedThing = require(path);
but we're not using RequireJS
.