pmndrs / uikit

🎨 user interfaces for react-three-fiber
https://pmndrs.github.io/uikit/docs/
Other
2.68k stars 138 forks source link

Pulling in Addons.js instead of linking to dependencies directly #87

Closed svnhub closed 4 months ago

svnhub commented 5 months ago

This is related to packages/uikit/src/components/icon.ts:31 packages/uikit/src/components/svg.ts:40 and to some extend examples/vanilla/index.ts:4

For build systems that do not feature tree shaking it may be excessive to pull in Three.js' entire Addons.js (all addons ever made) to link to just SVGLoader. We use a build system that runs inside the browser and in this example it has to pull down an additional ~250 files only to immediately throw them away again since they are not used by uikit.

Would it make more sense to link to the required modules directly?

Three.js do this in their own examples too https://github.com/mrdoob/three.js/blob/376f997ebd48f62c07dc735f245ba0fa933b0fff/examples/webgl_loader_svg.html#L36: import { SVGLoader } from 'three/addons/loaders/SVGLoader.js';