Skip to content
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

Combining gulp-typescript with browserify #166

Closed
johnnyreilly opened this issue Jul 20, 2015 · 4 comments
Closed

Combining gulp-typescript with browserify #166

johnnyreilly opened this issue Jul 20, 2015 · 4 comments

Comments

@johnnyreilly
Copy link

Hi,

I've done a little digging around but haven't found anything and so I thought I'd raise an issue here. Has anyone tried combining gulp-typescript with babel/browserify? I already have a project which is using babel and I want to try and move it across slowly to TypeScript. This means having browserify, babel and typescript in the mix together for a little while.

I'd initially tried using tsify but stumbled upon an issue related to external dependencies. So I'm wondering if anyone has any experience of gulp-typescript playing nicely with browserify?

@ivogabe
Copy link
Owner

ivogabe commented Jul 21, 2015

Browserify can't use a gulp stream as it's input. I've been using browserify in a different task:

  • task transpile: compile ts to js, save output to disk to a temporary directory
  • task bundle (dependency on transpile): call browserify on that directory

In your situation you could use 3 tasks:

  • transpile-babel
  • transpile-ts
  • bundle (dependency on transpile-babel & -ts)

If you don't want to write files to the disk, you could also use my project small:

var small = require('small').gulp;

var tsResult = gulp.src('lib/**/*.ts').pipe(ts({ module: 'commonjs' }));
var babelResult = gulp.src('lib/**/*.js').pipe(babel());
return merge([tsResult, babelResult])
    .pipe(small({
        outputFileName: {
            standalone: 'output.standalone.js'
        }
    }))
    .pipe(gulp.dest('dest'));

Note that small isn't very stable at the moment & doesn't support circular dependencies (but I'm working on that).

@johnnyreilly
Copy link
Author

Hi @ivogabe,

Thanks for the suggestions. I might try the writing to disk suggestion - though I wonder how performant that might be. The frustrating thing is trying to mix and match babel and TypeScript. Despite the best will in the world they're kind of fighting each other at present with my TSIFY experiments.

I may try writing to disk as you suggest with gulp-typescript and then having browerserify work on both the es6 code and the transpiled ts too. It's more painful than you'd hope at present....

@ivogabe
Copy link
Owner

ivogabe commented Sep 7, 2015

@johnnyreilly Ok if I close this? Or do you have some other question related to this?

@johnnyreilly
Copy link
Author

Go for it. I'm about to have another go now that 1.6 beta has shipped. I don't have a solution yet but there's no action required here in the meantime

@ivogabe ivogabe closed this as completed Sep 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants