Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Very familiar with Gulp and Angular, new to TypeScript. I have been using Browserify to bundle my JavaScript and manage the dependency tree but as I understand it I won't want to use Browserify alongside TypeScript.

Before I would have something like this in my main/entry point file.

require('angular');
require('angular-ui-router');
require('./myModules/testModule')
require('./myControllers/mainController')

angular.module('exampleApp', ['mainController','testModule'])

    .config(...);

}());

This would insure all of the necessary files were bundled into the final .js app in the appropriate order.

However with TypeScript (using gulp-typescript) the way to reference other files for building seems to be:

/// <reference path="myModule.ts"/>)

But this only works for other TypeScript files. How would I load my angular and other non TS deps?

For reference, my build looks like:

var jsStream = function() {
    return gulp.src(PUBLIC + '/js/**/*.ts')
        .pipe(typescript({
            declarationFiles: false,
            sortOutput: true,
            out: 'app.js'
        }))
        .pipe( streamify( rev() ) )
        .pipe( gulp.dest( PATHS.dest.js ) );
};
share|improve this question
    
I'm not sure if I understood your problem correctly, but this seems to be an answer you're looking for: stackoverflow.com/a/12930871/2148667 –  Kuba Jagoda May 10 at 7:50

1 Answer 1

TypeScript references like /// <reference path="myModule.ts"/> are used for transpilation to JS, resolving dependencies, as well as for Intellisense in a text editor or IDE. If you have existing libraries that you wish to reference in your TypeScript that aren't written in TypeScript, look no further than tsd and the DefinitelyTyped project on GitHub.

You can still use Browserify to bundle like you did before. The only difference is you need to transpile your TypeScript to JavaScript first via tsc or as you mentioned gulp-typescript. Once you have your TS as JS, bundle if with your other files like angular with Browserify. I have no idea if this plugin is any good, but there appears to be a TypeScript Browserify plugin called tsify. Maybe check that out as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.