#2306·systemjs

Possible dynamic import maps issue

Author: guybedfordCreated Mar 3, 2021Updated Sep 2, 2024
Labelsbug

Reposting from https://github.com/guybedford/import-maps-extensions/issues/7:

javascript
if dynamic add and import occurs asynchronously (e.g. after call or simply with setTimeout delay - **import fails:**

System.import('mod1');

setTimeout(() => { const script = document.createElement('script'); script.setAttribute('type', 'systemjs-importmap'); script.text = JSON.stringify({"imports": {"mod2": '/mod2/main.js'}}); document.head.appendChild(script);

System.import('mod2'); }, 1000);

**Unhandled Promise rejection: Unable to resolve bare specifier 'mod2'**

@DmitryBrus do you still get an issue if you add a delay before the System.import to allow for any possible async processing of the new import map?