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

Support/feature - tscserver / hooking into tsc --watch results #13608

Closed
ORESoftware opened this issue Jan 21, 2017 · 2 comments
Closed

Support/feature - tscserver / hooking into tsc --watch results #13608

ORESoftware opened this issue Jan 21, 2017 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@ORESoftware
Copy link

ORESoftware commented Jan 21, 2017

With these issues in mind:

#10879
#13588

I saw mention of "tscserver" - but I am not sure if that still exists - it sounds like that became tsc --watch?

What I want to do:

Compile a .tsx file on demand, and when it's done compiling, send a socket message to the browser, telling the browser that the file is compiled and ready to be loaded into the browser.

The problem:

The problem is thattsc --watchdoes not allow me to listen for when the compilation is finished.

Temporary solution:

So what I am currently doing now - instead of using tsc --watch, I am just running tsc as a child process on demand. When the child process closes, and exits with 0, I know compilation is done. And the problem is that it's a little bit slower this way, maybe 100 ms slower.

Longer term solution proposal:

As a better solution, it would be great to pre-start a Node.js process with tsc loaded already - essentially creating a tscserver, but I am not sure if this is possible. Alternatively, tsc --watch would allow me to somehow listen for compilation completion events.

To re-iterate, I am looking for:

  • (a) a way to hook into tsc --watch, to create actions that occur after compilation completes,

and/or

  • (b) a way to create tscserver that can process requests on demand, and where I can listen for compilation completion events.

Any help much appreciated, thanks.

@ORESoftware ORESoftware changed the title Support/feature - tscserver / hooking into tsc --watch results Support/feature - tscserver and/or hooking into tsc --watch results Jan 21, 2017
@ORESoftware ORESoftware changed the title Support/feature - tscserver and/or hooking into tsc --watch results Support/feature - tscserver / hooking into tsc --watch results Jan 21, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jan 21, 2017

The server supports a similar feature to tsc --watch, called compile-on-save, see https://github.com/Microsoft/TypeScript/blob/master/lib/protocol.d.ts#L893 for the server command.

tsc is just a command line tool, so running costume actions after it is done is really not in scope.

All the pieces that allow tsc --watch to work are available to you through the compiler API, so you should be able to build a process that watches changes, and calls the compiler when needed.

There are already existing tools like tsb that does more or less what you are asking for, i would recommend investigating these before building you own.

@ORESoftware
Copy link
Author

@mhegazy thanks

I opened an issue with tsb

jrieken/gulp-tsb#61

I am not sure if they have what I am looking for, I probably can't use Gulp for this.

#14722

@mhegazy mhegazy closed this as completed Apr 21, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants