gulp-typescript: Very slow incremental compilation (2.6x slower) compared to tsc
With “gulp-typescript”: “3.2.3”,
Expected behavior:
Should be as fast as tsc -w
Synchronizing program
Files: 289
Lines: 121510
Nodes: 524773
Identifiers: 184342
Symbols: 244975
Types: 51810
Memory used: 263018K
I/O read: 0.03s
I/O write: 0.09s
Parse time: 2.55s
Bind time: 0.63s
Check time: 4.13s
Emit time: 2.57s
Total time: 9.87s
9:21:12 PM - Compilation complete. Watching for file changes.
9:21:20 PM - File change detected. Starting incremental compilation...
Synchronizing program
...
Total time: 3.34s
9:21:23 PM - Compilation complete. Watching for file changes.
9:21:29 PM - File change detected. Starting incremental compilation...
Synchronizing program
...
Total time: 2.81s
Actual behavior:
Very slow, gulp does:
[21:17:49] Finished 'compileSources' after 9.31 s
... change a file ...
[21:18:04] Finished 'compileSources' after 7.4 s
Your gulpfile:
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
gulp.task('compileSources', () =>
tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest('artifacts'))
);
tsconfig.json
Include your tsconfig, if related to this issue.
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"importHelpers": true,
"outDir": "artifacts",
"rootDir": ".",
"rootDirs": [
"src",
"node_modules/include-common"
],
"sourceMap": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true,
"lib": ["dom", "es2017", "es2016", "es2015"],
"baseUrl": ".",
"paths": {
"escodegen": ["node_modules/escodegen"],
"esprima": ["node_modules/esprima"],
"esquery": ["node_modules/esquery"],
"firebase": ["node_modules/firebase"],
"firebase-admin": ["node_modules/firebase-admin"],
"firebase-safekey": ["node_modules/firebase-safekey"],
"include-common/*": ["node_modules/include-common/*"]
},
"skipLibCheck": true,
"types": [
"color",
"d3-format",
"d3-scale",
"esprima",
"estree",
"react",
"react-native",
"react-native-fs",
"react-navigation",
"react-redux",
"redux-actions"
]
},
"compileOnSave": false,
"include": [
"ourTypings/**/*.d.ts",
"src/**/*.ts",
"src/**/*.tsx",
"node_modules/include-common/**/*.ts",
"node_modules/include-common/**/*.tsx"
],
"exclude": [
"android",
"artifacts",
"gruntfile.js",
"node_modules/include-common/artifacts",
"node_modules/include-common/node_modules"
]
}
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 3
- Comments: 29 (8 by maintainers)
That completes in 100ms for me. Testing it looks like tsc 2.7.2 takes the same amount of time (if not longer) on the first compile, and then is nearly instant for later compiles. It’s a lot more than 2.6x now, close to 100x faster (0.07 seconds vs 6.6 seconds). gulp-typescript seems to always take 6-8 seconds.
Looking at the diagnostics difference I think tsc is not reloading all the types for each incremental compile (57770 for first compile, 238 for second, see below) while gulp-typescript is.
gulpfile.js
Output from gulp-typescript
Output from tsc
tsc with --diagnostics turned on
I’ve posted an answer on your StackOverflow question, let me know if anything is unclear.
@ivogabe I tried the alpha.1, unfortunately the results are the same (even worse in most cases). Previous build during watch (when saving a file, without modifying its content) was taking ~10 seconds, it’s taking up twice as long with the alpha.
@marcghorayeb I don’t. I keep tsc running and rerun gulp whenever I want to publish/start the application.