Typescript output order - gulp tsc equivalent with tsconfig.json

Given the tsconfig file and the use of the tsc command line, everything works as it should. However, using gulp-typescriptthe specified tsconfig.jsonand outFilecreates another output order - my problem is that I can not find a way to create a gulp of the same javascript, that tsc.

Our build workflow is gulp based; but it tscis a gold standard, has a good browsing function, and has extensive tool support (e.g. http://dev.ivogabe.com/using-vscode-with-gulp-typescript/ ). It would be great if I could make our gulp build work the same as tsc.

An example tsconfig.json:

{
  "compilerOptions": {
    "declaration": false,
    "preserveConstEnums": true,
    "outFile": "out/out.js",
    "sourceMap": true,
    "target": "es5",
    "noEmitOnError": true
  },
  "exclude": [
    "node_modules",
    "out"
  ]
}

An example 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('out'));
});
gulp.task('default', ['typescript:compile']);

, , tsc tsconfig.json; gulp gulpfile.js tsconfig.json ( gulp-typescript) typescript. , .

, tsc gulp-typescript, . gulp-typescript tsconfig , tsc.

, "child-process".exec tsc, gulp-typescript gulp; gulp, typescript ( tsconfig.json), .

+4

Source: https://habr.com/ru/post/1627827/


All Articles