This content originally appeared on Bram.us and was authored by Bramus!
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!
This content originally appeared on Bram.us and was authored by Bramus!
Bramus! | Sciencx (2021-09-13T20:24:42+00:00) Support Import Maps in any browser with es-module-shims. Retrieved from https://www.scien.cx/2021/09/13/support-import-maps-in-any-browser-with-es-module-shims/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.