kotas / gulp-tsc

gulp.js plugin for compiling TypeScript files
69 stars 37 forks source link

Fix broken backward compatibility with output file path #18

Closed kotas closed 10 years ago

kotas commented 10 years ago

For issue #17

By changing the strategy how to capture output files from tsc in 7156ee45a1e1e3b4a16a7f3189d9405a3db31a74, path of output files changed accidentally in some cases. This commit fixes it.

When input paths have any common path, tsc skips that common path and uses only different part of the path for output files.

For example, if we have "foo/bar/a.ts" and "foo/bar/baz/b.ts", tsc skips "foo/bar/" automatically and outputs "a.ts" and "baz/b.ts". gulp-tsc followed that rule implicitly by changing the strategy.

However, this is not ideal for gulp tasks since with gulp.src("foo/*/.ts") the plugin should use "bar/a.ts" and "bar/baz/b.ts" for output paths.

To fix this, we add common part of input paths to output paths.

bestander commented 10 years ago

Hi, thanks for the best gulp tsc task. I think this pull request broke my build and I reverted to version 0.5.0.

This is my setup:

gulp.task('compile-typescript', function() {
    return gulp.src(['app/**/*.ts'])
        .pipe(cache('typescript'))
        .pipe(typescript(typescriptOptions))
        .pipe(gulp.dest(webOutputPath + '/app'));
});
gulp.task('dev', function(callback) {
    runSequence('clean-web-output',
        ['compile-typescript', 'compile-sass' ],//, 'run-tests'],
        function() {
            gulp.watch(['app/**/*.ts'], ['compile-typescript']);
        });
});

If I change one TS file I expect 1 or more JS files to be compiled into my .tmp folder.

For example if I change:

/app/online-reader/popup-reader-directive.ts

Then compiler produces this list:

<tmp>/online-reader/popup-reader-directive.js
<tmp>/online-reader/reader-preferences-service.js
<tmp>/analytics/http-latency-sampler.js

The change in this ticket changes it to:

<tmp>/online-reader/online-reader/popup-reader-directive.js
<tmp>/online-reader/online-reader/reader-preferences-service.js
<tmp>/online-reader/analytics/http-latency-sampler.js

Which os wrong.

I am happy to debug or provide more test data.

kotas commented 10 years ago

@bestander Thank you for your report! I've made the issue above for the problem. It'll be considered to be a bug.

kotas commented 10 years ago

@bestander I've published v0.6.0. Please check if it fixes your problem. Thank you!