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)

Most upvoted comments

Normal build: Screen Shot 2020-09-23 at 7 23 32 AM Added OrbitControls to src/Three.js:

Screen Shot 2020-09-23 at 7 24 18 AM

Resulting build: Screen Shot 2020-09-23 at 7 25 44 AM

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.js file that has OrbitControls inside. He is adding export { OrbitControls } from '../examples/jsm/controls/OrbitControls.js'; to ./src/Three.js and because OrbitControls is importing three.module.js then 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:

  • three.js
  • three.min.js
  • three.module.js

Files from examples/jsm, such as OrbitControls, depend on three.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.