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

Feature request: "onBeforeCompilation" or "cleanOutDir" option #93

Closed
rfox12 opened this issue May 26, 2020 · 4 comments
Closed

Feature request: "onBeforeCompilation" or "cleanOutDir" option #93

rfox12 opened this issue May 26, 2020 · 4 comments

Comments

@rfox12
Copy link

rfox12 commented May 26, 2020

One of the big pain points in using any kind of "watcher" with typescript is: cleaning up the output folder before compilation begins.

See related issue: microsoft/TypeScript#16057

It would be nice of tsc-watch gave us the capability to run something before every compilation. Perhaps a --cleanOutDir flag that would clean the output folder every time before compilation. Or a --onBeforeCompilation option that would allow us to run some custom code. Or both!

@rfox12
Copy link
Author

rfox12 commented May 26, 2020

I ran into a bug using tsc-watch today and it was because of old files in my outDir.

@gilamran
Copy link
Owner

In the current situation, I don't think that it's possible to halt the compilation before it starts...
Also, I'm not sure that it's a good idea, typescript has an incremental build that will only compile the changed files.
What was you bug?

@rfox12
Copy link
Author

rfox12 commented May 27, 2020

Yeah I took at peek at the code and realized you don't really have a clean hook--you can close this. I am dynamcially loading a directory of imports (handlers). That's how I noticed old files/handlers were still active with new builds where the files have been deleted.

I think the best that tsc-watch could do would be: flag a warning after each "Success" to inform the user if there are files in outDir which have a "created date" significantly far way from compile completion. In my case when inspecting the outDir manually it was pretty easy to see that almost every file had an created date of 1:31pm, but a few files had 1:25pm or even earlier. Hard to say what the default threshold should be...

So I don't have a PR for you... but perhaps a flag like --warnCreatedThreshold 5 could mean: warn me if files in the outDir were created at least 5 minutes before the compilation completion.

@gilamran
Copy link
Owner

But as said before typescript supports incremental compilation, meaning that files will have totally different times...

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

2 participants