three.js: Custom build produces files too large
Simply trying to add OrbitControls to three.min.js by following the instructions in the Wiki. Working from a fresh clone of the master branch of r120 on a Windows 10 machine with current Node and npm. Added the line
export { OrbitControls } from '../examples/jsm/controls/OrbitControls.js';
to src/Three.js and ran npm install followed by npm run build-closure. The resulting file is twice as big as expected, and further runs of the build keep increasing file sizes. Either something critical is missing from the Wiki instructions or there is an error somewhere.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (15 by maintainers)
Normal build:
Added
OrbitControlstosrc/Three.js:Resulting build:
Not sure this is a duplicate actually.
If I understand it correctly, what @paulmasson is trying to do is to create a new
three.min.jsfile that hasOrbitControlsinside. He is addingexport { OrbitControls } from '../examples/jsm/controls/OrbitControls.js';to./src/Three.jsand becauseOrbitControlsis importingthree.module.jsthen the build ends up twice as big.Once again, this wouldn’t be a problem is import maps were in browsers already.
Let me give this a try.
three.js has three possible versions of the core library:
Files from
examples/jsm, such as OrbitControls, depend onthree.module.js. So you’ll need to make sure your application does the same, or you’ll get two copies. If you’re having trouble getting this to work I would recommend posting more details about your custom build on https://discourse.threejs.org/ and we’ll be able to help there.