Jump to content

starting BJS + TS + Sublime Text


jerome
 Share

Recommended Posts

Ok, inspected it further.

I just pushed a PR to github with a fix that I hope will solve this entire thing.

https://github.com/BabylonJS/Babylon.js/pull/403

It is an update to the gulpfile and npm's package file, including new dependencies. BabylonJS supports typescript 1.0.? at the moment, and this fix forces the typescript compiler to be this version.

Map files are generated, declaration files are generated as well (if wanted).

Wait for DK to merge it or simply update your gulpfile and package files.

 

Next thing would be to solve the compatibility issues with typescript 1.4

PR for ts 1.3 is here - https://github.com/BabylonJS/Babylon.js/pull/404

Edited by RaananW
Link to comment
Share on other sites

tested ....

 

 

 

 

 

suspense

 

 

 

 

Works  :D

 

However the typescript-to-js task didn't work at first run (despite I installed and updated dependencies) : it missed the merge2 npm module.

Added manually (as sudoer) :

npm install merge2

Now it works !!!

Every ts file is well compiled into js file with TS 1.4

 

Congratulations RaananW :)  

Link to comment
Share on other sites

Yep, this is what I did when it claimed for merge2 (don't know why)

Anyway, that's not important as I manually added it.

 

The important thing is that YOU achieved to give us a updated (and updatable) working environment  ;)

 

Thanks again

Link to comment
Share on other sites

  • 4 weeks later...

I'd like to post my working environnement to this thread http://www.html5gamedevs.com/topic/12460-contribution-validated-working-environments/

but I have a last micro trouble with my setup :

 

When I compile TS to JS, all my JS files are mapped this way

//# sourceMappingURL=../Actions/babylon.actionManager.js.map

instead of that way :

//# sourceMappingURL=babylon.actionManager.js.map

 

And that's pretty annoying because Git thinks that I have to commit all those JS files at each slightest tiny little change.

 

I'm using gulp 3.8.1, tsc 1.4.1.0, gulp-sourcemaps 1.3.0 and the BJS/Tools/Gulp/gulpfile.js with no modification.

 

Any idea ?

Link to comment
Share on other sites

This is caused due to the different way those files are compiled in different machines.

I'll try checking if gulp can reference the map files differently, maybe this will solve the problem for you. Thou if I remember correctly it also adds an extra empty line for some reason.

I'll check and let you know.

Btw, when I use gulp I always revert all changes in .js files after compiling (except the main babylon files), this way I have an updated version and git didn't go all crazy :-)

Link to comment
Share on other sites

I personally use TortoiseGit which has this option in its UI. I am pretty sure all git UI interface has this option one way or another. Might be names differently (Tortoise is, I think, an SVN-oriented Git client :-) so revert comes from SVN in that case. I think native git people would call this "discard". But I might be wrong ;) ).

Link to comment
Share on other sites

I also only commit the changed TS and revert all JS, to keep branch and PR merging as clean as possible.

I'm using GitExtension and there also simply is an option to do that easily (I was previously using Tortoise for SVN but once starting Git I tried many clients and found GitExtension the more powerfull, easy, and versatile).

Link to comment
Share on other sites

here :

SublimeText 2 + git plugin used to commit edited TS files individually

SmartGit or git command line to manage fetch/checkout/branches/merge/push

Gulp (the provided bjs recipe) to compile and build in order to test locally

 

however, I don't know how to revert all compiled js files at once

Link to comment
Share on other sites

  • 1 year later...

I have spent hours trying to jump into typescript for the first time with sublime text.

Sublime Text will compile my typescript and if I manually copy over the .js files it creates I can get my game to run.

However I am trying to automate with Gulp and Browserify and I am getting compile errors. I don't understand what I am supposed to do and it's getting frustrating. I'm surprised there is no example or tutorial that covers this situation. If I can get it working then I will publish a how-to for newbies. I think a lot of people must have been in the same position as me and given up.

Errors I get from my Gulp:

 

events.js:161
      throw er; // Unhandled 'error' event
      ^
TypeScript error: node_modules/typescript/lib/lib.d.ts(5603,11): Error TS2320: Interface 'AudioContext' cannot simultaneously extend types 'AudioContextBase' and 'EventTarget'.
  Named property 'addEventListener' of types 'AudioContextBase' and 'EventTarget' are not identical.

 

Link to comment
Share on other sites

I would recommend to systematically use the command line : "gulp typescript" what makes plenty of tests and build the library for you.

Moreover, it's updated by the core team each time some internal dependencies are added, so you don't have to care about all this stuff.

 

[EDIT] now I use VSCODE editor for linux what works out-of-the-box with typescript and BJS

Link to comment
Share on other sites

I have continued to fail to get browserify working for this, but I do have gulp-typescript working for now.

If anyone comes here from google, here is the most basic TypeScript build gulpfile.js that you can use as a starting point:

 

 

'use strict';

var gulp = require('gulp');
var ts = require("gulp-typescript");

var paths = {
    pages: ['index.html'],
    ts: [
        'ts/babylon.2.5.d.ts',
        'ts/game.ts',
    ]
};

gulp.task("ts", function () {
    return gulp.src(paths.ts)
        .pipe(
            ts({
                //noImplicitAny: true, 
                module: 'amd',
                target: 'es5',
                declaration: false,
                sourceMap: true,
                removeComments: false,
                //out: 'output.js'
            })
        )
        .pipe(gulp.dest('dist/js'));
});

 

 

- You do NOT need to add an 'export' line to babylon.d.ts.

- You do NOT need an import line in your game.ts to reference babylon.d.ts.

- Put babylon.d.ts and game.ts in the "files" section of your tsconfig.json.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...