4 ms·
but the use-case for these is not a static import (that is possible already), but a dynamic one, such as: await import(`${config.providerType}.js`); and
by pornel 10y ago
but the use-case for these is not a static import (that is possible already), but a dynamic one, such as:
await import(`${config.providerType}.js`);
and this can't be resolved at tokenization phase (and brute-forcing it with speculative/symbolic execution would be too much of a hack IMHO).
- domenicd 10y agoYes, indeed. If your app actually depends on dynamically-loaded information before it can continue, then of course your app needs to block further evaluation. Top-level await simply allows you to express that without placing the rest of your app inside async functions.