For future reference: Set up your importmaps ASAP in Firefox. It can break if you have too many other scripts that load first.
Howdy, I’m building a page that renders a simple Three.JS scene, and it works great in Edge, Chrome, and even Safari thanks to es-module-shims.
But not Firefox.
Until the middle of last December, Firefox didn’t support importmap. As of version 108, it does, and I’m running version 110. So Firefox should support importmap, but my page isn’t working.
My importmap is set up as follows:
<script async src="https://ga.jspm.io/npm:es-module-shims@1.6.3/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "./js/three.js-master/build/three.module.js",
"three/addons/": "./js/three.js-master/examples/jsm/"
}
}
</script>
And my javascript does its importing as follows:
import * as THREE from 'three';
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
The error I get in Firefox is:
Uncaught TypeError: The specifier “three” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
At first it seemed like the shim was to blame, and I swear that one single time the page worked in Firefox when I commented out the shim. But since then, nothing. Firefox is just convinced it doesn’t support ImportMap (which it supports as of two version ago).
One wrinkle… it also worked at random one single other time, with no code changes from the previous refresh, and then stopped working again
Live demo: Loads on Chrome, iOS Safari, but not Firefox
Anyone encountered this, anyone found a workaround, or am I doing something wrong? I’ve been over all the documentation and examples I can find VERY thoroughly…