Hersir Posted April 12, 2017 Share Posted April 12, 2017 Hi, if I use import { Engine } from "babylonjs"; I get error that babylon.d.ts is not a model. Looks like that export = BABYLON is missing at the end of file. Could it be added or there is reason why it is missing? I saw this thread but looks like it still is missing in git Quote Link to comment Share on other sites More sharing options...
Hersir Posted April 12, 2017 Author Share Posted April 12, 2017 Just updated to 3.0.0 alpha from npm and it works now, sorry for false alarm. Quote Link to comment Share on other sites More sharing options...
Hersir Posted April 12, 2017 Author Share Posted April 12, 2017 Now I just need to expose BABYLON to window as global variable, but I found a way how to do it with webpack loaders GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted April 12, 2017 Share Posted April 12, 2017 Do you mind sharing the code changes for your solution? I'm struggling with ES6 imports! Quote Link to comment Share on other sites More sharing options...
Hersir Posted April 13, 2017 Author Share Posted April 13, 2017 @brianzinn Sure, what you wanted to know ?, I have Typescript + Webpack build. So Type definitions started to work out of the box from 3.0-alpha version of Babylon. Import then: import * as BABYLON from "babylonjs"; Works also with direct imports import { Engine } from "babylonjs"; For webpack I needed to expose babylonjs as global var, for that I used expose-loader Loader list of webpack: { test: require.resolve("babylonjs"), loader: "expose-loader?BABYLON" } brianzinn 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted April 14, 2017 Share Posted April 14, 2017 { test: require.resolve('babylonjs'), use: [{ loader: 'expose-loader', options: 'BABYLON' }] Thanks. Slightly different syntax for webpack2. Just wanted to see if having a project in Typescript + webpack would allow me to import the Canvas2D (import .. from 'babylonjs/canvas2d'), but it doesn't Error is that it is not a module canvas2d.d.ts. It was worth a try! Cheers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.