With the current, latest version of TS (v2.5.x) it is possible to do dynamically import a module using a variable instead of hard coding it?
For example:
let modName: string = "myModule";
const myMod = await import(modName);
When I use a variable, I get an error "Cannot find module '.'". It looks like the TS is transpiling it to that line of code when I use a variable, so it is irrelevant what I set that variable to.
I have looked at these relevant threads:
Dynamically import module in TypeScript TypeScript ES dynamic `import()`
modNamebut usemodon the next line?Promise.resolve().then(function(){return!function(){var e=new Error('Cannot find module "."');throw e.code="MODULE_NOT_FOUND",e}()}). I am using WebPack and Uglify, which is why the code looks like this. If I use a hardcoded string:Promise.resolve().then(function(){return o("my-module-name")})