gulp-typescript: gulp-typescript substantially slower than tsc
I realize this is a bit of a vague issue, but I’d really love to get some ideas how I could speed this up. I have an existing build that I’m adding TypeScript to, and noticing substantial performance differences between compiling with gulp-typescript vs. tsc. The actual numbers:
time tsc
tsc 1.65s user 0.07s system 139% cpu 1.232 total
time gulp compile:typescript
gulp compile:typescript 6.25s user 0.92s system 116% cpu 6.134 total
The gulp task is pretty minimal:
const gulp = require('gulp')
const typescript = require('gulp-typescript')
const tsProject = typescript.createProject('tsconfig.json', {
typescript: require('typescript')
})
gulp.task('compile:typescript', function() {
return tsProject.src()
.pipe(typescript(tsProject)).js
.pipe(gulp.dest('app'))
})
As is the tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": false,
"outDir": "app",
"rootDir": "server-src",
"noImplicitAny": true
},
"exclude": [
".git",
"node_modules",
"typings/browser.d.ts",
"typings/browser",
"typings/main",
]
}
Some random other stuff that could potentially be contributing:
- As I mentioned I’m adding TypeScript to an existing project. The source directory contains a lot of es6 files with
.js
extensions, but only a couple of TypeScript files.- I would hope that using
tsProject
and the sametsconfig.json
would ensure they’re scanning the same files though, and I’ve monitored the build dir withfswatch
and confirmed that bothtsc
andgulp compile:typescript
are writing the same set of output files.
- I would hope that using
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 26 (10 by maintainers)
Commits related to this issue
- current state for comment on https://github.com/ivogabe/gulp-typescript/issues/326 — committed to lucastheisen/test-js-maven by deleted user 8 years ago
- Use TypeScript api to resolve files of tsconfig.json Fixes #326, #404, #406 — committed to JakeJP/gulp-typescript by ivogabe 8 years ago
I’m using gulp.src on a folder with 4 ts file and it takes almost 3 seconds, really slow.
Don’t want to steal any of this project’s thunder, but in case it’s useful to anyone I ended up porting my typescript watch task to just fork off a
tsc --watch
process. It’s a bit of a hack (parses thetsc
output to make the task output more consistent with other gulp watch tasks) but I’ve been using it for over a month on a real project without any issues. It took my incremental compile times from ~25 seconds to about 3 to 4 seconds.In ff163bfc1571e458f5d8e8a68c5a49c3869de123, I’ve removed the glob that
tsProject.src
used which was extremely slow. The TypeScript api is now used to resolve the files. That proces is synchronous, but it will still be faster in most situations. Another benefit is that the behavior is now exactly the same astsc
, previously there were some edge cases that didn’t work correctly. Since I believe thattsProject.src
caused the performance issues mentioned in this topic, I think that this can be closed. If someone still experiences performance problems, please open a new issue.