Stupid question by a newbie

Hello, I’m testing the Babylon 5.0 alpha version.

With the 4.2 release I can import the whole BABYLON namespace,
and my bundle size is about 3.5Mb

With the 5.0 release if I import the whole namespace in this way
import * as BABYLON from “@babylonjs/core/Legacy/legacy”
my bundle size is about 11Mb

So, I have to carefully choose which class to import

but, despite this, my bundle size is always bigger than a full import with the 4.2

Maybe is it because it’s not minified … ?
Does someone can explain me why there’s a so huge difference?

Furthermore, how can I import “Tools” so to use “Tools.ToRadians” (I can’t find it anywhere…) ?
Many thanks!

Hello @DanieleSuppo!
Does it make sense to use ES6 and BJS 5.0 and still use the legacy classes? Do you have a specific reason for this? :slight_smile:

Adding on roland’s comment, Babylon has strong backwards compatibility with old versions, so your existing 4.2 code should work on 5.0. :smiley:


As Roland said, there is no need to load the entire namespace, which is the reason your bundle size is so big.
load the specific files from their specific directories (and not directly from the main directory @babylonjs/core alone), and make sure not to use the legacy endpoint, which is mainly used in the UMD package.

The babylon package includes unminified code for your convenience, as a final step for production release I would recommend you to minify your code (using a bundler will help here)


Many thanks to all for your reply,
I’ve realized that with 4.2 I was using the minified version of BJS, so that’s normal.