Typescript and buolding babylonjs

Hello all,

I’m not new to programming, more a backend programmer, c#, c++, work with gpu in typed languages, not a stranger to javascript/typescript but by no means good at either of these (back in the day i was, but since then modules and all sorts of things have arrived).

So to it: tasked with researching babylonjs, got a decent demo working, built using typescript and so on, webpack, it outputs a bundle.js. So i figured i’d take bundle.js - which has all my classes compiled in from typescript, along with babylonjs i presume and use it in another project.

Not so easy. Managed to use many of the classes, but now i wanted to use modules and import some of the clases, and derive from them in my new webproject that consumes it. I’ve spent weeks on this, and in the end i’m just hacking through it, making it work with ugly code. I know i am missing something, require is for server side (this is for clientside), and my new webproject just wants to use the classes that i know are already in the bundle.js (which i’ve scripted in as a module). When i try to extend one of the classes it fails saying my class “is not defined”, though i can seem to instantiate the same class in code all the same (which makes no sense to me at all). I assumed the modules etc was to make life easier, but my experience has been anything but.

I’m probably approaching this all wrong, but weeks of google, and i’m still none the wiser? Anyone know how to go about this?

This might help a bit Babylon.js ES6 support with Tree Shaking | Babylon.js Documentation as well as this project all setup in an easy way to get started GitHub - RaananW/babylonjs-webpack-es6: Babylon.js basic scene with typescript, webpack, es6 modules, editorconfig, eslint, hot loading and more. Will even make coffee if you ask nicely.

1 Like