I have a fairly simple scene, but the build after tree-shaking, is still over 3.5MB. It’s a modern (ES6) build from TypeScript code using rollup (built under Vite, since I’m working with Vue). rollup-plugin-analyzer
is showing some surprising bits included, such as colorPicker
, so I’m wondering if I’m importing correctly.
I’m not using import * from...
, and since I’m using MeshBuilder
directly, I don’t have to import any “side effects.”
The docs (here)[Babylon.js ES6 support with Tree Shaking | Babylon.js Documentation] show two forms of imports:
import { Engine, Scene } from "@babylonjs/core";
and
import { Engine } from "@babylonjs/core/Engines/engine";
import { Scene } from "@babylonjs/core/scene";
Is the second one preferred, especially w/r/t tree-shaking?
(This thread)[TS ES6 module imports: how to quickly find module to import? - Questions - Babylon.js] suggests that the latter is the better option, though it requires more work to figure out the individual paths, but before I go replace all of my import statements, I figured I should check here first.
There’s also a note about directly importing individual mesh-building functions rather than importing MeshBuilder
, so I’m already looking into doing that, but I don’t suspect that is responsible for the majority of my bundle size.