Hacker News new | ask | show | jobs
by SahAssar 1091 days ago
> (you can still do like `import('foo' + someVar)` which will only invoke dynamically at runtime, so I'm not sure how that case is dealt with)

That case is dealt with more like a `fetch('foo' + someVar).then(r => eval(r.text()))` or similar (but of course it is not just a eval and it instead returns the exports of the module).

Dynamic imports and static ones behave very differently and static analysis generally ignores dynamic imports IIRC.

You also need to treat dynamic imports as async including everything that comes with that (error checking, awaiting, etc.)