Hello,
I am totally new to Three. js and try to integrate three. js into a chrome extension for a university project. But instead of the ES module I need the UMD version, which I can’t find in the latest three. js version (V. 161).
Can someone tell me where I can find it or how to solve the problem or if there are alternative ways to make three. js usable in a Chrome extension?
The build files build/three.js
and build/three.min.js
have been removed with r161
since they are unusable with addons. You have to switch to ES modules, use a build tool or stick to an older three.js release.
Related guide: three.js docs
Thank you for your quick reply.
when I try to use an older version (V.160) the chrome extension immediately reports this “error” and therefore cannot execute the extension. Is there any way we can change that?
What build-tool do you mean? Can you explain me a solution how i can use three.js for a extension?
Sorry, I’m not familiar with developing Chrome extensions.
With build tools I mean tools like webpack, rollup or vite.
You could try to drag-and-drop three.module.js
here: https://boytchev.github.io/demoduler/, then download the de-moduled version. However, before doing this, consider:
- Using non-moduled Three.js is a step backwards, you will run in problems that escalate exponentially as your project gets bigger
- The demoduler is supposed to work on addon modules, so I’m not sure whether the produced demoduled Three.js will be functioning at all
- The demoduler is not supported any more, I used it for an year, as a grace period
- The demoduler is stupid, it will definitely not work with minified files, so do not try to demodule
three.module.min.js
It looks like there are more resources for building chrome extensions in the way you require using esm, browsers have been moving towards supporting es6 imports for a while and I’m not sure chrome will continue to support UMD in this context in the near future, as @PavelBoytchev has outlined, using UMD, es5 and outdated build tools is behind us, esm / 6 is the way forwards, it shouldn’t take a lot to get to grips with… javascript - How to import ES6 modules in content script for Chrome Extension - Stack Overflow