JavaScript Import Maps – which I wrote about earlier here — are a great addition to the web. Unfortunately they’re only supported in Chromium 89+.
Thankfully there’s a polyfill available: es-module-shims
. As long as your browser has baseline ES Module Support (Chrome 61+, Firefox 60+, Safari 10.1+, and Edge 17+) the polyfill will work.
To use it, include the script and then write your first import map. The polyfill will automagically do its thing.
<script async src="https://unpkg.com/es-module-shims@0.13.1/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"app": "./src/app.js"
}
}
</script>
<script type="module">
import app from 'app';
// …
</script>
Also polyfills other things such as Dynamic Imports … NEAT!