You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typescript recompile app two times in watch mode with non recursive watching on os like linux #37994
I googled a lot of info during the day, tried to update tsc version, reinstalled modules, excluded different directories in ts.config but nothing helps.
P.S. there is only ONE compiling if I run nodemon --watch 'src/**/*.ts' --exec 'tsc' -e ts
Did you try
using typescript nightly drop to see if the issue is fixed. If not give exact details of what changes are you making to which file and log by running tsc --w --extendedDiagnostics.
changed the title [-]Typescript recompile app two times in watch mode[/-][+]Typescript recompile app two times in watch mode with non recursive watching on os like linux[/+]on May 1, 2020
I am experiencing an issue that I think is related to this issue.
For my project, I am have a project root with two dirs: src and dist. I build all files from src with outDir set to ./dist. Also, I use tsc-watch to execute the main js file from the dist file automatically when compilation passes.
Problem
When the node app runs, it ensures a directory exists in CWD (set to ./dist). The creation of the new folder in the dist folder triggers a recompile of the entire app.
What should happen:
File changes inside outDir, should not be regarded as a change to the input files.
Cause
See my diagnostics below, but possible cause also present in logs above.
Just after the project has been compiled and the time diagnostics are printed. One additional directory watch is created, on the project root dir. This recursive watch causes the outDir to also be watched.
Solution
Either (allow for) exclude of outDir of watches, or do not watch the project dir (but there probably is good reason to do so).
I forgot to mention that this issue is introduced by delayed child watcher updates (#35615)
Meanwhile you can work around this by passing --synchronousWatchDirectory
Activity
sheetalkamat commentedon Apr 29, 2020
This does not repro with build from master.
baleksandr48 commentedon Apr 30, 2020
So, I have to upload built version?
sheetalkamat commentedon Apr 30, 2020
Did you try
using typescript nightly drop to see if the issue is fixed. If not give exact details of what changes are you making to which file and log by running
tsc --w --extendedDiagnostics.baleksandr48 commentedon May 1, 2020
I removed typescript from
package.json, added--extendedDiagnosticsflag tobuild:watchand runmy output:
after updating main.ts file and saving:
Also I pushed this updated project: https://github.com/baleksandr48/tsc-bug
[-]Typescript recompile app two times in watch mode[/-][+]Typescript recompile app two times in watch mode with non recursive watching on os like linux[/+]maritaria commentedon May 7, 2020
I am experiencing an issue that I think is related to this issue.
For my project, I am have a project root with two dirs:
srcanddist. I build all files fromsrcwithoutDirset to./dist. Also, I usetsc-watchto execute the main js file from thedistfile automatically when compilation passes.Problem
When the node app runs, it ensures a directory exists in CWD (set to
./dist). The creation of the new folder in thedistfolder triggers a recompile of the entire app.What should happen:
File changes inside
outDir, should not be regarded as a change to the input files.Cause
See my diagnostics below, but possible cause also present in logs above.
Just after the project has been compiled and the time diagnostics are printed. One additional directory watch is created, on the project root dir. This recursive watch causes the
outDirto also be watched.Solution
Either (allow for) exclude of
outDirof watches, or do not watch the project dir (but there probably is good reason to do so).Environment
package.json
{ "name": "storage-api", "version": "1.0.0", "main": "dist/index.js", "author": "SNIP", "license": "SNIP", "scripts": { "serve": "tsc-watch --extendedDiagnostics --listEmittedFiles --noClear --onSuccess \"sh -c 'cd dist && node ./index.js'\"", "build": "tsc" }, "dependencies": { "body-parser": "^1.19.0", "express": "^4.17.1" }, "devDependencies": { "@types/express": "^4.17.6", "@types/node": "^13.13.5", "tsc-watch": "^4.2.3", "tslint": "^6.1.2", "typescript": "^3.8.3" } }Installed package versions
Compilation log
Notes: running inside a docker composition (image:
node:14)maritaria commentedon May 7, 2020
I just found a workaround for my issue, should it help those reading along. I changed my structure to make the
srcdirectory the project root.Changes to
project.json:Changes to
tsconfig.json, also moved from./to./src.eigenbeam commentedon May 21, 2020
If it helps: I encountered this problem on our project using 3.8.3.
sheetalkamat commentedon May 21, 2020
I forgot to mention that this issue is introduced by delayed child watcher updates (#35615)
Meanwhile you can work around this by passing
--synchronousWatchDirectoryIf there is no changes to folder structure when watching directories …
Fixes issues with reload because of output emit (#39030)
jgonera commentedon Feb 5, 2021
This is still happening for me on TypeScript 4.1.3. Is the fix included in that release?