I’ve completed a basic working port of Babylon.js ported to use Rollup instead of Gulp + Webpack. You can see my ongoing work at https://github.com/Symbitic/Babylon.js. When it’s complete, Gulp can be removed entirely, and Webpack can be used for just the web applications.
It’s not feature complete yet. It doesn’t build the web apps. It doesn’t build minified yet. It doesn’t handle linting or emitting typescript definitions. And it doesn’t bundle all the separate modules (Core, Gui, Loader, etc) into a single file for single distribution. I’m working on it.
But it does build both ES6 modules and UMD JavaScript for the Core, GUI, Loaders, Materials, PostProcess, ProceduralTextures, and Serializers. All in about 30 seconds.
Why use Rollup
Right now, Babylon is tightly integrated with its build system. That hampers maintainability.
Rollup generates much smaller bundles than Webpack. It can also handle building multiple formats at once.
It also means we can transition away from that Gulp + Webpack mess Babylon currently uses. Rollup builds with just one command: $ npm run build
. And since Rollup is installed automatically, that means no more globally-installed packages.
The only two files used for the entire build process are rollup.config.js
and rollup-plugin-babylon.js
in the root directory. Try checking them out - I don’t even need to use the Tools/Config/
files.
Using
Just run npm run build
. That’s it.
Files are placed in ./dist/rollup/
. I added this directory to .gitignore
, since I really don’t think repos should be committing built files - they should be using NPM and a CDN like UNPKG for that.
I have tested (though not extensively), and both the ES6 and UMD modules for Core can be loaded in Node.js, though the others (GUI, Loader) don’t work only because they require the “babylonjs” module installed (which it isn’t during development). The UMD modules for Core, GUI, Loaders, and all others load successfully in the browser and are available under the usual BABYLON.
Future
Obviously, I plan to add things like minified builds soon.
I hope to start porting things like linting, testing, type emitting and typedoc away from Gulp tasks and to NPM scripts, IF the developers are okay with that.
One thing I would like to do in the future is port to using the new Babel TypeScript preset. It offers faster compile times, it’s MUCH faster when running in watch mode, it doesn’t give you annoying error messages when you don’t want them. It has a preset for automatically transpiling to support even the oldest of web browsers. It allows us to use the very latest JavaScript syntax and plugins. I would post the links but I’m only allowed two links per post.
Help
I am hoping to submit a pull request soon, if the developers are okay with it. But first, I would like to get feedback.
Do people think this is a good idea to begin with? Is there something I should change?
I welcome any and all feedback.