Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gulp-typescript and outFile option in tsconfig.json

I'm using gulpfile.js to compile my tsconfig.json project this way:

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

var tsProject = ts.createProject('Modeler/tsconfig.json',
    { typescript: require('typescript') });

gulp.task('build:ts', function () {
    var tsResult = tsProject.src()
        .pipe(ts(tsProject));
    return tsResult.pipe(gulp.dest('wwwroot/app'));
});

It works ok and compiles my typescript files and put js files into wwwroot/app folder

The problem arises then I want TypeScript compiler to output single concatenated file using outFile property

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs",
    "outFile": "modeler.js"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]  
}

The gulp task does create an empty output file and creates *.js files with content next to *.ts files.

What should I fix to create desired output file without polluting my source folders?

like image 850
Roman Kolesnikov Avatar asked Dec 19 '22 23:12

Roman Kolesnikov


1 Answers

Are you sure you don't have external modules in your TypeScript sources?

I've encountered similar behavior in that case. External modules are not allowed when using outFile option, but compiler does not complain and emits empty file. Additionally external modules should be emitted "somewhere" (in outDir).

If the problem is not about external modules using plain tsc -p . behaves the same way as using gulp-typescript?

like image 61
ahz Avatar answered Dec 26 '22 05:12

ahz