Importing examples jsm modules causes bundlers to bundle three.js source code twice
See original GitHub issueImporting from three/examples/jsm/.../<module>
causes bundlers (tested with rollup) to include the library twice (or multiple times).
For example, when doing import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
, the bundler will follow the import and in the OrbitControls.js the imports come from ../../../build/three.module.js
. However, there is no way for the (external) bundler to know that ../../../build/three.module.js
is the same module as three
.
A solution for this would be to treat the examples modules as external packages and import from three
instead of ../../../build/three.module.js
. This might break the rollup config of three.js, but it should be possible to tell rollup that three
is an alias for the main entry point of three (src/Three.js
).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:79 (30 by maintainers)
Top GitHub Comments
@gkjohnson @donmccurdy
I think I’m all for adopting https://skypack.dev/ and having a script that converts “…/build/three.module.js” to “three” at
npm publish
time 👍I think it’s just something to get used to. Now that I think I get it I’m fine with the way it is.
BTW I updated threejsfundamentals to all be esm based so 🤞