tsc -w is unacceptably slow
I'm on windows. Typescript version installed via npm is 1.7.5. When I do tsc -w typescript watches for changes but its change detection is really slow. I takes about 10s before it notices I made a change and then recompiles.
What could be causing this?
Edit: Node 5.3.0
Is the .ts file in your node_modules folder referenced by your file somewhere? If so it is supposed to be watched. I tried to put a random .ts file in the node_modules folder and didn't see changes were picked up. Can you confirm?
Also, it would be of great help if you can put the error log when the tsc -w is not working stably, or point me to a sample project that could lead to a repro. Thanks!
@zhengbli
In my case @next gives an error not present in 1.7.3:
> tsc -p . --sourceRoot app
node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2661:
Cannot re-export name that is not defined in the module.
That's what I used to generate the previously described problem:
$ touch node_modules/angular2/src/facade/promise.d.ts
This triggers the change detection. I'm not explicitly referencing that file anywhere.
I'll try to get a sample project together...
@zhengbli
You could try https://github.com/fergusg/my-ng2-sandbox which is what I'm using. I'm slightly embarrassed to point you at that messy hack job (not intended for anyone but me) which is a learning pit for angular 2, but what the hell...
@fergusg this error is caused by the fix for https://github.com/Microsoft/TypeScript/issues/6323, I will send a fix for the angular package to address the issue.
@fergusg Thanks for the sample! Is this where the watching doesn't work consistently? I tried editing all .ts files in the app folder, and all changes were detected, so if there is a problem, it is not caused by the file name. Did you see the issue after a long session? How often do you see it stopped working?
@zhengbli Sorry, I can't reproduce reliably :-(
I edit .ts files (Visual Studio Code FWIW) and mostly those changes are detected. But "from time to time" tsc -w just stops picking up those changes. Completely. Only restarting tsc -w fixes it.
@zhengbli To answer your questions more explicitly:
Did you see the issue after a long session? I saw it even after a minute or so with only 2 or 3
.tssavesHow often do you see it stopped working? 3 or 4 times in my recent session (2 hrs with constant saves)
I've run several tests and its very slow with TypeScript 1.7+. I wrote lite-server which runs browser-sync. If I run tsc with a watch and browser-sync, on typescript v 1.6 it takes about 2 seconds to reload the page when i have a 1s delay on browser sync. this is awesome.
If I run the same thing with typescript 1.7.5 or typescript@next, it takes 20+ seconds
you can repeat this by pulling the https://github.com/johnpapa/angular2-tour-of-heroes sample, npm i and run npm start from the command line.
UPDATE
if I use npm install typescript@next it is now working quickly. maybe a new rev since i last tried. here is what i have exactly
"typescript": "^1.8.0-dev.20160119"
@johnpapa a fix for the slowness in watching mode was merged in master last week, so the one in typescripe@next has the fix in.
i see 1.8 is in this repo, is it going to npm shortly too?
we are closing down on 1.8 bugs. we should have something out in the next few weeks. typescript@next now should be very close to the final 1.8 drop.
ok. i saw the version here https://github.com/Microsoft/TypeScript/blob/master/package.json#L5 and got excited and confused :)
:) we bump up the version in master once we ship to make sure that nighties have the correct version number.
@fergusg I have the same issue:
node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2661:
Cannot re-export name that is not defined in the module.
Is it a bug in tsc or in Angular?
EDIT: might be related to #6323
this is the issue in angular, I think that the fix is already submitted
im on 1.8.10 and the problem continues on mac. that same version on windows is instantaneous. in fact it's identical package.json file as i'm following the ng2 quick start template. for some reason on a mac the changes take 5-20s to be detected
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.1",
"@angular/upgrade": "2.0.0-rc.1",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.11",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings":"^1.0.4"
}
@johnpapa running npm install typings@next screwed me up with this error https://github.com/typings/typings/issues/554
fixed it by running typings install env~node -SG, but all this did not do anything for tsc change detection speed.
actually never mind, much faster now :)
I am using Node Js ver 7.8.0 and file watcher is taking loads of time recognizing my file changes. My typescript ver is 2.2.1.
@sumant30 Can you share your tsconfig.json / OS / file system? You are using the tsc -w right?