Published unlisted
Edited
Sep 6, 2022
Insert cell
Insert cell
// This works; as per https://observablehq.com/@observablehq/how-to-require-stubborn-modules#THREE
THREE = (window.THREE = require("three@0.99.0/build/three.min.js"))
Insert cell
// The require resolves to the following URL
require.resolve("three@0.99.0/build/three.min.js")
Insert cell
/* Require-ing a child module doesn't work.
Module require debugger ( https://observablehq.com/@observablehq/module-require-debugger ) says:
"This module doesn’t seem to be published on NPM. Perhaps the module name is incorrect or mistyped, or the module’s author hasn’t published it yet?"
*/
require("three@0.99.0/examples/js/loaders/GLTFLoader.js")
Insert cell
// Unsing stubborn add-ons pattern doesn't work either
// https://observablehq.com/@observablehq/how-to-require-stubborn-modules#THREE
require("three@0.99.0/examples/js/loaders/GLTFLoader.js").catch(() => {})
Insert cell
// However, the URL for the module does have content
gltfURL = require.resolve("three@0.99.0/examples/js/loaders/GLTFLoader.js")
Insert cell
Insert cell
// Even attempting to require it directly, via the url, fails as well
require(gltfURL).catch(() => {})
Insert cell
// Per this recommendation: https://talk.observablehq.com/t/upward-compatability-module-loader-issue/7001/2
// Still an issue.
THREE2 = {
const THREE = (window.THREE =
await require("three@0.99.0/build/three.min.js"));
await require("three@0.99.0/examples/js/loaders/GLTFLoader.js").catch(
() => {}
);
return THREE;
}
Insert cell
THREE2.GLTFLoader
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more