I have a project that uses Babylon reasonably minimally - just scenes and meshes and textures, no animations or loaders etc. I recently updated it to Babylon 4.2, and noticed that the bundle size, for babylon libraries only, is about 3.2MB (unzipped).
Is this normal? My vague recollection is that when I started using Babylon the unzipped size was around 500k.
Details: I am building with webpack 4, production mode, with tree-shaking etc. The babylon libraries I’m importing are:
import { Scene } from '@babylonjs/core/scene'
import { Engine } from '@babylonjs/core/Engines/engine'
import { Mesh } from '@babylonjs/core/Meshes/mesh'
import { SubMesh } from '@babylonjs/core/Meshes/subMesh'
import { Texture } from '@babylonjs/core/Materials/Textures/texture'
import { VertexData } from '@babylonjs/core/Meshes/mesh.vertexData'
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial'
import { MultiMaterial } from '@babylonjs/core/Materials/multiMaterial'
import { FreeCamera } from '@babylonjs/core/Cameras/freeCamera'
import { HemisphericLight } from '@babylonjs/core/Lights/hemisphericLight'
import { Octree } from '@babylonjs/core/Culling/Octrees/octree'
import { OctreeBlock } from '@babylonjs/core/Culling/Octrees/octreeBlock'
import { OctreeSceneComponent } from '@babylonjs/core/Culling/Octrees/'
import { Vector3, Color3 } from '@babylonjs/core/Maths/math'
import { SolidParticleSystem } from '@babylonjs/core/Particles/solidParticleSystem'
import '@babylonjs/core/Meshes/meshBuilder'
Which i’m guessing from the thread above is actually just importing all of the core at 9.37mib. Sounds like the solution is specifying the path to the specific library. But to your question above @fenomas, how do you figure out what the path is? I was digging around the node modules, but it wasn’t always obvious what path you need for which import. Like how did you know that VertexData needed ‘@babylonjs/core/Meshes/mesh.vertexData’? Is there a map somewhere?
Or, i guess a better example of one that is hard to find is your other one:
import { VertexBuffer } from '@babylonjs/core/Meshes/buffer'
If you search through the @babylonjs node_modules dir by name “VertexBuffer”, there’s none that match by name. And if you search by content, there are too many matches to be useful.