gulp-typescript
gulp-typescript copied to clipboard
Parallelise typecheck and file emit using gulp-typescript
Expected behavior: I am trying to improve build performance of my project by concurrently triggering "tsc --noEmit" and "gulp" in parallel threads. I would've expected gulp to skip type checking if I set isolatedModules to true and only emit js, dts files. Actual behavior: If isolated modules is set to true, declaration flag gets set to false in project setup. Due to this .d.ts files are not emitted. Here's the code from project.js: if (options.isolatedModules) { options.newLine = typescript.NewLineKind.LineFeed; options.sourceMap = false; options.declaration = false; options.inlineSourceMap = true; }
Your gulpfile:
Include your gulpfile, or only the related task (with ts.createProject).
var tsProject = ts.createProject("tsconfig.json", { declaration: true });
gulp.task("js", function() {
return tsProject
.src()
.pipe(tsProject())
.js.pipe(gulp.dest("dist"));
});
gulp.task("dts", () => {
return tsProject
.src()
.pipe(tsProject())
.dts.pipe(gulp.dest("dist"));
});
gulp.task("default", gulp.series("js", "dts"));
tsconfig.json
Include your tsconfig, if related to this issue.
{
"compileOnSave": true,
"compilerOptions": {
"moduleResolution": "Node",
"esModuleInterop": true,
"module": "commonjs",
"target": "es6",
"sourceMap": true,
"alwaysStrict": true,
"outDir": "./dist",
"rootDir": "./src",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"tsBuildInfoFile": "./.tsBuildInfoFile"
},
"include": ["./src/"],
"exclude": ["node_modules"]
}
Code
Include your TypeScript code, if necessary.