Support Import Maps in any browser with es-module-shims

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!

es-module-shims (GitHub) →

About the author

Bramus is a Freelance Web Developer from Belgium. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.