kant2002 / gulp-tsc

gulp.js plugin for compiling TypeScript files
MIT License
16 stars 11 forks source link

Gulp-tsc runs in infinite loop #20

Closed Elfayer closed 7 years ago

Elfayer commented 8 years ago

I guess i did something wrong, but I don't understand why starting with :

image

I end up with : (I had to stop the script from running, otherwise it never stops adding files and folders)

image

While the file is correctly compiled...

Here is my script :

var gulp = require('gulp');
var typescript = require('gulp-tsc');

gulp.task('compileTS', function() {
    gulp.src(['**/*.ts', '!node_modules/**'])
    .pipe(typescript({
        target: 'ES5'
    }))
    .pipe(gulp.dest('.'));
});

gulp.task('watch:ts', function() {
    gulp.watch(['**/*.ts', '!node_modules/**'], ['compileTS']);
});

I just ran the gulp watch:ts command.

kant2002 commented 8 years ago

@Elfayer gulp-tsc create file to keep tree. since watch see new file in the tree created, it relaunch new task, before other is appearing. In order to prevent gulp-tsc from create new script each time it compile you could add property keepTree: false to you options.

var gulp = require('gulp');
var typescript = require('gulp-tsc');

gulp.task('compileTS', function() {
    gulp.src(['**/*.ts', '!node_modules/**'])
    .pipe(typescript({
        target: 'ES5',
        keepTree: false
    }))
    .pipe(gulp.dest('.'));
});

gulp.task('watch:ts', function() {
    gulp.watch(['**/*.ts', '!node_modules/**'], ['compileTS']);
});