-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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 -w" will compile and watch, then how to run tsc in "watch-only" mode without compiling? #12996
Comments
I suppose we could add this, but it'd need to be well-hidden enough that people wouldn't accidently use it and think TS was broken for not compiling the first time around. I'm assuming they wrote their script that way so that |
currentlly tsc will update the file if it has changed since the last time it wrote it. we can make it so that it reads the output file the first time if it exists. |
I think the fact that All I'm looking for is something like |
I run into this as well. It's useful to be able to compile or watch or compile + watch. |
Couldn't we just remove the first 'tsc' from that line of code? |
But then, @mhvj, it might still be compiling when the server is already started? |
IMO the essential features here are:
I'm affected by this usually when chaining watchers for dev-mode over a complex multy-project workspace. for instance several typescript watchers that produce dependencies for each other, and a webpack-dev-server that bundles all their target files whenever any of them change. |
TL;DR: This is exactly the same problem @yaooluu described above It'll be great to have this, could be useful for monorepos (e.g. managed by lerna), where you have multiple packages that you want to test (I mean cross-package / integration testing). |
if understand correctly, to start working on this and have a chance that my PR will be accepted this feature needs to
according to CONTRIBUTING what should be done to make it approved? does it need just more feedback or I can start working on it, submit a PR and only then it could be approved? |
@mhegazy thoughts on taking a PR for a flag to skip the initial watch cycle? |
This needs to be done. |
Sure, we would consider a PR for it. |
Just as an aside, I'm using https://github.com/gilamran/tsc-watch which extends the built-in compiler with an "start": "tsc-watch --project . --outDir ./dist --onSuccess \"nodemon ./dist/bin/www.js\"" (Another aside: it seems the above does not work with projects in subfolders, such as |
@gilamran and I both work at the same place, and I've been waiting for this feature for months |
sorry guys, I'm unable to work on the issue right now (not using ts in the current project), hope someone else will take it over |
@amir-arad, @avbentem You should use |
@itsUndefined That's the whole point of |
In my opinion this should be part of |
You can temporarily run a delay.js between the two scripts. if (delay !== parseInt(delay, 10).toString()) { setTimeout(() => { process.exit(0); }, delay); |
Guys, I really need this feature. |
@Lian-LF, @SteppeEagle You can still use tsc-watch instead of |
the problem of |
@SteppeEagle Look at this. Here you can do what ever you want when the compilation succeeded of failed |
this is how I do it this will start nodemon 3 seconds after tsc -w |
^^
|
This is very much needed. Babel CLI has My use case is a Lerna monorepo with libraries and demos, you need to build all libs as phase 1 and then run demos + watch on phase 2, so the more libs you have the more inefficient it becomes. Currently the watch procedure looks like this: {
"scripts": {
"build": "lerna run build --scope=@xxx/lib-* --concurrency=1 --stream",
"start": "npm run build && lerna run start --parallel"
}
} Since Lerna's |
Any resolution on this? Our app is freaky twitchy, each time I run a watch script it reloads the whole process 3 times before the changes stop coming from the initial build. It's insane. |
@pronebird have you considered using |
@gilamran yeah that's definitely one thing I consider to use. But AFAIK it's less elegant than having a first class support in |
|
Any update here? |
I created a package called runmon to work around this very issue. |
|
@sheetalkamat can you elaborate how that enables us to use |
@pronebird You can read more about --incremental at https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#faster-subsequent-builds-with-the---incremental-flag |
@sheetalkamat perfecto, seems to be working! |
@sheetalkamat now I got it. Thank you! |
+1 any update on this? |
I think |
I disagree with the above statement. here is the workflow I have setup: I am running a node server inside of a docker container with the folder structure
I want to run a single start command inside of the docker container, i.e.
with the following package.json scripts:
with this setup, i have a tsc watching for any files changes in On start, I have to perform a fresh build and copy since tsc watch does not allow for post-compile scripts to run (such as copying over non-ts files), and then I have tsc:watch setup to rebuild, and thus restart the server anytime ts files change. What tends to happen here is that my server will startup right away, but then since build:watch always performs a rebuild, this causes my server to autoreload everytime I start it up. This is quite annoying since the app will work, and then suddenly a network error is thrown after the ~3 second tsc rebuild. Since the server startup takes about 3-5 seconds, this makes the server start time go from 3 seconds to about 10-15 seconds everytime the docker image is booted. This was so annoying that I had to start my server with two commands and i just run build:watch outside of the docker container. it;s quite easy to forget to run both commands and really tricky bugs have come out of just not having the build:watch command running in another window. This workflow could be fixed by either allowing:
|
Try
Some way of knowing when |
Is this added? I run TS in watch mode and it doesn't compile. I would like to turn this on |
TypeScript Version: 2.0.3
Hi, I'm finding it confusing when using "tsc -w". From angular quickstart guide and almost every tutorial, I see similar things in package.json as the line below:
Expected behavior:
The command should compile only once, and then "watch" and "start lite-server" at the same time.
Actual behavior:
The command compiles once first. Then "compile and watch" and "start lite-server" at the same time. The actual result is it compiled twice.
I'm finding this annoying especially when running with karma (which watches for JS file changes).
From the above code, when
karma start karma.conf.js
runs, tests start running. At the same time (due toconcurrently
), "tsc -w" starts running and fires another round of TS compilation, which changed the output JS files. Then Karma detected these JS file changes, stopped the currently running (partially or finished) tests, and started re-run the tests again.I've only find the tsc documentation explaining "tsc -w" as "Run the compiler in watch mode. Watch input files and trigger recompilation on changes.".
https://www.typescriptlang.org/docs/handbook/compiler-options.html
From my understanding, what we wanted from
"tsc && concurrently 'tsc -w' 'do-something' "
iscompile && (watch and do-something concurrently)
. But we actually got"compile && (compile-then-watch and do-something concurrently
. Do we have any options to make "tsc -w" only watch, but don't compile?The text was updated successfully, but these errors were encountered: