I need to do something like:
if (condition) {
import something from 'something';
}
// ...
if (something) {
something.doStuff();
}
The above code does not compile; it throws SyntaxError: ... 'import' and 'export' may only appear at the top level
.
I tried using System.import
as shown here, but I don’t know where System
comes from. Is it an ES6 proposal that didn’t end up being accepted? The link to “programmatic API” from that article dumps me to a deprecated docs page.