For a long time threejs had trouble with commonjs environments, see #17220 It affects all jsm files that mutate the namespace, ReactAreaLights for instance.
A dirty workaround existed:
import * as THREECJS from 'three' import * as THREE from 'three/build/three.module' Object.assign(THREE, THREECJS)
It works around threeejs broken module resolution by merging the two namespaces that it creates into one. (And yes, using threejs+jsm in cjs currently loads two versions of the same library with two separate namespaces). But something in threejs took that away recently:
Cannot set property ACESFilmicToneMapping of #<Object> which has only a getter
Could threejs please remove cjs? By offering
"main": "build/three.js" it appears as if it does support cjs, but jsm most definitively doesn’t, since it refers to
I don’t understand for whom that cjs file is for tbh. You can’t use any third party lib or add-on reliably, including examples/jsm – and in every case you’re loading threejs twice. Why would anyone want this? It’s causing so much trouble, i can’t count the bug tickets i get b/c of this. It would be such a relief to see that file go, or at least the entry in package.json.