I'm using Import Maps on my website which (according to caniuse.com) aren't supported on Firefox v107 or the latest (non-TP) version of Safari. I thought that the es-module-shims polyfill library would add support, but it doesn't seem to be working.
I have code that works perfectly as soon as I enable Import Maps in about:config
(or when I visit my page on Chrome), but the same code throws an error in the console on Firefox v107.
Am I using the polyfill incorrectly or doing something unsupported?
I have this code in the <head>
of my page:
<script src="//unpkg.com/es-module-shims/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three/examples/fonts/": "./node_modules/three/examples/fonts/",
"three/examples/jsm/": "./node_modules/three/examples/jsm/",
"three": "./node_modules/three/build/three.module.js"
}
}
</script>
<script type="module" defer src="index.js"></script>
In my index.js
, I have a dynamic import:
if (location.pathname === "/" || location.pathname === "/index.html") {
import("./module/hero.js");
}
At the top of my module/hero.js
, I have a static import to Three.js:
import * as THREE from "three";