Use ES6 modules without BABYLON namespace in Babylon Native

@BabylonNative

Continuing the discussion from Babylon native load script:

As you know, we’re using Babylon React Native at present but I’m wanting to do some testing with just Babylon Native and I can see how experience.js can be replaced or other scripts loaded, but I’m confused if and how we can import other js from there (will that work in the BN context?) and also, our private npm packages have Babylon.js as an external dependency and don’t use the BABYLON namespace, so how would I integrate these for testing in BN?

@inteja , BN currently does not support import. The way BN works is that it gives you a very low level access to the Javascript runtime and the scripts goes directly into it.

The ordering in which scripts are imported and their dependencies must be managed by the consuming application. That’s why we do the import in our samples starting with “babylon.max.js” and than loading “experience.js”.

The ideal workflow for a complex project with multiple Javascript files and dependencies would be to have a separate pipeline for bundling Javascript and to just provide the final bundle.js to BN. This would support things like Typescript and consuming Babylon.js without using the BABYLON namespace.

3 Likes

Thanks @srzerbetto . I’ll give it a try.