Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsc-watch compiles/starts 2x/change and ramp-up is slow #85

Closed
desmap opened this issue May 5, 2020 · 15 comments
Closed

tsc-watch compiles/starts 2x/change and ramp-up is slow #85

desmap opened this issue May 5, 2020 · 15 comments

Comments

@desmap
Copy link

desmap commented May 5, 2020

"dev": "tsc-watch --noClear --onSuccess \"node dist\"" compiles and starts always 2x/change. When replacing node by nodemon and --onSuccess by --onFirstSuccess it compiles and starts properly once per change. But even then it feels sluggish.

FWIW, meanwhile, I use "dev": "concurrently \"tsc -w\" \"nodemon dist\"" which works properly (1x compile & start/change) and is quite snappy.

@desmap desmap changed the title tsc-watch watch compiles/starts 2x/change and ramp-up is slow tsc-watch compiles/starts 2x/change and ramp-up is slow May 5, 2020
@gilamran
Copy link
Owner

gilamran commented May 5, 2020

Sorry, I don't understand what is the problem and what you mean by 2x/change.
Please provide a short "story" of what you try and what's wrong.

@desmap
Copy link
Author

desmap commented May 5, 2020

Thanks for the quick response.

On file change tsc-watch compiles and starts the app two times. IDK how I can describe it better. It just does everything two times.

More infos: in tsconfig I specified "include": ["src/**/*"] and my outDir is ./dist and I run the whole thing in a Docker container.

@gilamran
Copy link
Owner

gilamran commented May 5, 2020

You are probably doing something wrong, it doesn't suppose to do it twice for sure.
I'll need you to provide, your setup, like folder structure, package.json, anything that will allow me to reproduce this.

@desmap
Copy link
Author

desmap commented May 5, 2020

Thanks for your support! Since I switched already to concurrently + nodemon I would need to go back. I could do this the later the day. I really tinkered with tsc-watch few hours and couldn't get it working properly and fast.

Maybe you just try my solution and compare output and speed with your solution in a Docker container (until I can try tsc-watch again) and you might find the issue with tsc-watch yourself.

@desmap
Copy link
Author

desmap commented May 5, 2020

didnt test it but maybe helpful for you: if sourceMap is true, always two build files (js + map) are generated and hence your lib is doing everything twice while nodemon has a default delay of 1sec before it restarts and hence just restarts once. maybe it's that??

@desmap
Copy link
Author

desmap commented May 5, 2020

here man, fyi, you get even more control on tsc's watch technique (tldr default fswatch is unreliable):

https://www.typescriptlang.org/docs/handbook/configuring-watch.html

I am just testing eg RecursiveDirectoryUsingDynamicPriorityPolling and things get even faster!

@gilamran
Copy link
Owner

gilamran commented May 5, 2020

Regarding "fswatch is unreliable", I will test it.

Regarding your problem, the source maps shouldn't cause any issue... I'm using typescript to detect compilation complete, and then just run the onSuccess command.
There's no need for nodemon when using tsc-watch

I still don't understand how to reproduce your problem... I need some way to see that happen... maybe just create a repo.? allow me to see your repo.? share your setup? something...
I'm shooting here in the dark

@gilamran
Copy link
Owner

gilamran commented May 5, 2020

Maybe you are allowing typescript js files, and typescript is also "looking" into the dist folder and then detects new files there because of its own compilation?

@desmap
Copy link
Author

desmap commented May 9, 2020

sorry that I haven't come back yet, I remember that the compilation steps are caused by a file and a directory compile trigger which again do not happen with nodemon because you have an default delay of 1 sec. i try to setup an example repo hopefully next week

@gilamran
Copy link
Owner

Hi, did you test your issue?

  • I don't want to leave orphan issues open.

@hillaryan
Copy link

hillaryan commented Jul 3, 2020

@gilamran I ran into this issue as well. Here is how I would describe it with my project:

Every change causes the compiler to run twice. The first run is brief (<1s) and is cut short by the second run, which completes successfully.

@hillaryan
Copy link

hillaryan commented Jul 3, 2020

@desmap Removing tsc-watch and directly running tsc -watch shows the same double run. So the problem has nothing to do with this package.

Update: the relevant typescript issue is here: microsoft/TypeScript#37994 and adding the synchronousWatchDirectory flag worked for me.

@gilamran
Copy link
Owner

gilamran commented Jul 4, 2020

@hillaryan Thanks for the update and the issue follow.

@gilamran gilamran closed this as completed Jul 4, 2020
@CanTheAlmighty
Copy link

CanTheAlmighty commented Nov 25, 2022

Same issue, rolling back to Typescript 4.8.4 solves the issue in the meantime (it's a typescript issue)

@gilamran
Copy link
Owner

gilamran commented Dec 1, 2022

Looks like this issue was closed, is this still happening for you on the latest typescript?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants