"Ee: invalid module" error. The module tries to use observable's variable

I am tying to use THREE.js lib and one of it’s sub-libs (GLTFExporter.js).

When I require GLTFExporter.js I got “Ee: invalid module” error.
Console throws the error (see screenshot).
Inside this module we have “THREE.GLTFExporter = function () {};”.
So the script tries to extend THREE.js module but cant see it.
THREE = require("three@0.99.0/build/three.min.js", "three@0.99.0/examples/js/exporters/GLTFExporter.js") doesnt work too.

When I copy the content of GLTFExporter.js to separate cell it woks well but this way is not convenient though.

Is there some workaround to require this module in usual way?

Here is the example: https://beta.observablehq.com/@sen77/ee-invalid-module-error-when-require-js-file

Here the screenshot of the error:

Try it this way: https://beta.observablehq.com/d/e0a5e8b26e3a6d16

For more tips be sure to check out @tom’s guide: https://beta.observablehq.com/@tmcw/requiring-modules-troubleshooting#THREE

2 Likes