After setting up a tsconfig file and successfully running the command-line tsc, I encountered an issue when using gulp-typescript with a tsconfig.json and outFile specified. The output ordering was different, and I have been unable to find a solution in Gulp to generate the same JavaScript as tsc.
Our build process relies heavily on gulp; however, tsc is considered the industry standard due to its watch feature and widespread tooling support. It would be ideal if we could align our gulp-based build process with tsc for consistency.
Here is an example of the tsconfig.json file:
{
"compilerOptions": {
"declaration": false,
"preserveConstEnums": true,
"outFile": "out/out.js",
"sourceMap": true,
"target": "es5",
"noEmitOnError": true
},
"exclude": [
"node_modules",
"out"
]
}
And here is an example of the gulpfile.js:
"use strict";
var gulp = require('gulp');
var typescript = require('gulp-typescript');
var tsProject = typescript.createProject('tsconfig.json');
gulp.task('typescript:compile', function () {
var tsResult = tsProject.src()
.pipe(typescript(tsProject));
return tsResult.js.pipe(gulp.dest('assemblage'));
});
gulp.task('default', ['typescript:compile']);
The discrepancy between tsc and gulp-typescript output ordering impacts a non-trivial directory of TypeScript files. Developers should be able to switch between the two build processes seamlessly without encountering any output ordering issues.
Unfortunately, I don't comprehend the distinction in output ordering rules applied by tsc and gulp-typescript, making it challenging to recreate the problem. Ideally, gulp-typescript using a tsconfig project should follow the same order as tsc.
I have contemplated utilizing "child-process".exec to invoke tsc, but I prefer the superior integration of gulp-typescript with Gulp. Additionally, I am open to exploring other gulp plugins that directly call the TypeScript compiler using the tsconfig.json project file, although I haven't discovered one yet.