ES6 version incoming


The packages are all deployed here: Babylon.js Documentation

They currently do not list their side effects so you need to create imports targetting modules and not the index files to benefit from tree shaking. we are currently hard working to list the side effects and enhance the discovery.


Congrats, Bavs! A truly marvelous accomplishment… seriously. (hug)


@sebavan I’m getting a “ReferenceError: earcut is not defined at new PolygonMeshBuilder” any idea?


You either need to define earcut as a var in webpack or you can import earcut and pass it to the constructor of the PolygonMeshBuilder iin the 4th parameter. I ll add some part in the documentation for this today.


so either:

import * as MyEarcut from "earcut";
new PolygonMeshBuilder("polytri", corners, scene, MyEarcut);

or in your webpack config:

module.exports = {
    context: __dirname,
    plugins: [
        new webpack.ProvidePlugin({
            'earcut': 'earcut'


@sebavan thanks a lot, found it.
the problem is that I’m using MeshBuilder.CreatePolygon which doesn’t pass the earcut parameter to `PolygonMeshBuilder.
I’ll open an issue.

btw you have a typo in the docs “Please not that you can not mix ES6 and our legacy packages.”


Finally! from 500kb gzip to 150kb gzip!
70% less!


YEAAHHHHHH pretty happy and thanks for your feedbacks it helps a lot ensuring the full stability in 4.0 :slight_smile:


Deployed “@babylonjs/core@4.0.0-alpha.18” and “@babylonjs/gui@^4.0.0-alpha.18” to production env already. besides the issues I already opened everything works perfectly!
major improvement in loading times, thanks. (which was one of our challenges)


That is a GOOOD news! Thanks for reporting back!


Typo fixed and 19 is out. the earcut injection is here Allow earcut injection through meshbuilder methods · BabylonJS/Babylon.js@3e27bcb · GitHub and will be available in alpha 20


I’ve tested the new alpha in both angular and react, and all typings work out of the box, and the bundle size is way down, so awesome job with the modernization :slight_smile:


Sweet, thanks for sharing :slight_smile: