-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Babylon.js tree shaking #58
Comments
Hi, yes, some BJS folks have asked me to support this and I'd like to do it properly! But I'm not sure how best to go about it. First, note that I've just pushed a build to the var noaEngine = require('noa-engine')
var babylonJS = require('babylonjs')
var noa = noaEngine({
babylon: babylonJS,
}) Now with that said, the problem currently with import is that import { Engine } from '@babylonjs/core/Engines/engine'
import { Scene } from '@babylonjs/core/scene'
import { Vector3 } from '@ babylonjs/core/Maths/math'
// .. and all the other classes noa needs
var noa = noaEngine({
babylon: {
Scene,
Engine,
Vector3,
// ...
},
}) I assume this would work but it's not a nice solution. The alternative would be for Is your solution the same as one of those, or do you see other alternatives? |
Another option would be to declare @babylonjs/core as a peer depency in the noa's package.json as shown in this branch. Feel free to merge it if you want that approach, – otherwise I'll just pass the babylon modules as a parameter to noa, which works fine for me :) |
Hey, thanks for that link! It looks like I should do exactly that. I should probably also switch the rest of the code from I'll work on this, thanks! |
I dove into this and it's working, but there were some complications. As a result I have pushed a branch to this repo that now uses https://github.com/andyhall/noa-examples Can you do me a huge favor, and try pointing your project at the noa branch
Since these are big changes I'd really like to confirm that it works for someone besides me 😁 Thanks! |
It works :) (sorry about the late reply, – I was on vacation) |
Cheers mate! I will push a release pretty soon. |
This is pushed to #master and also npm as Let me know if anything breaks! |
The distribution size is reduced significantly when loading the babylon modules individually, rather than including the entire
babylon.js
. For a production build ofdocs/hello-world
the total size reduces from 2.5MB to 1MB.Would you like a pull-request to noa, where it depends on
@babylonjs/core
, and imports that withimport
instead ofrequire
?Otherwise I'll just continue as I do now by creating a custom
window.BABYLON
in my code, – and I might add some notes here about how to do that, in case others want to do the same.The text was updated successfully, but these errors were encountered: