What's the best way to use babylon as modules but also stay in sync with the nightly builds / branches?

I get that there can not be new npm package versions every night.

How do some people go about using Babylon in their npm/webpack based project as a repo instead of from npm itself. Also how does that factor into your CI/CD process ?

Finding more than once that new bugfixes and features are available and it’s painful waiting for a new npm version to test them out.

1 Like

We are super flexible to build new release. Simply ask :slight_smile:

1 Like

Oh, could use one then to test a recent bug fix. Thanks :slight_smile:

I thought maybe some people out there were using local modules or something

If you are using ES6 modules you can checkout the repository itself and follow the contribution guidelines to get that started. At that point you can run gulp npmPackages-es6. Going forwards you can run git pull to build the latest from source control. What it does is npm link the modules and then you can check them out in your project like npm link @babylonjs/core. That’s definitely a more complicated way to work against recent fixes, for example. Easiest way is to wait for NPM or request a nightly build :slight_smile:

2 Likes

Thanks, I might give that a try and see how jenkins likes it too :thinking:

I made a small script to automate what @brianzinn explained. I don’t recommend using it if you don’t understand what it’s doing or use it all the time. Can be nice to test preview though without having to bother @Deltakosh too much. Also makes it easier to start contributing, if you want to point it at your own fork instead.

const path = require('path');
const util = require('util');
const fs = require('fs-extra');
const exec = util.promisify(require('child_process').exec);
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

const currentDir = process.cwd()
const parentDir =  path.dirname(currentDir)

if (fs.existsSync(`${parentDir}/Babylon.js`)) {
    rl.question("Do you want to pull and rebuild Babylon ? (y/n)", function(answer) {
        const answerCased = answer.toLowerCase()
        rl.close();
        if (answerCased === 'y') {
            exec(`cd .. && cd Babylon.js && git pull origin preview && npm install && cd Tools/Gulp && gulp npmPackages-es6`)
        } else {
            console.log("Babylon.js engine update skipped")
        }
      });
} else {
    rl.close();
    console.log("Cloning and building Babylon.js preview branch...")
    exec(`cd .. && git clone git@github.com:BabylonJS/Babylon.js.git --branch preview --depth 1 && cd Babylon.js && npm install && cd Tools/Gulp && gulp npmPackages-es6`)
} 

This gets added to package.json as

"preinstall": "buildBabylon.js"

and the modules become:

"@babylonjs/core": "../Babylon.js/dist",
"@babylonjs/inspector": "../Babylon.js/dist/inspector",
"@babylonjs/loaders": "../Babylon.js/dist/loaders",

This requires the prerequisite packages from the getting started contributing guide. Keep it mind it will make a Babylon.js folder one directory out from wherever your project is.

npm install -g typescript
npm install -g gulp@4.0.0
1 Like

The answer from brianzinn above is best if symlinks work for you. (i.e. npm link)

However, when running an IDE like Intellij IDEA on Windows, but building Babylon.js in WSL2, that won’t work well because WSL2 doesn’t support symlinks from windows. As a result, Intellij IDEA can’t see the symlinks in the /node_modules folder.

(Intellij is working on solutions, but nothing great yet AFAIK. VS Code doesn’t have this problem if using Remote - WSL).

So to do a quick build and check of nightly, an alternative is to pack the newly built modules and install them:


# Build packages (will also npm link them, but can be problematic with Windows/WSL2)
cd  <babylon-path>/Tools/Gulp
git pull
gulp npmPackages-es6

# Change to your project and pack/install required modules
cd <your-project-dir>
npm install $(npm pack <babylon-path>/.temp/packageES6Dev/core | tail -1)
npm install $(npm pack <babylon-path>/.temp/packageES6Dev/gui | tail -1)

The package.json will contain entries like this:

  "@babylonjs/core": "file:babylonjs-core-5.0.0-beta.11.tgz",
  "@babylonjs/gui": "file:babylonjs-gui-5.0.0-beta.11.tgz",
1 Like