Reputation: 15542
As far as I can tell, Deno always compiles TypeScript to JS on startup, and has no "watch" mode. It's also my understanding that there is no such thing as "incremental compilation" for TypeScript aside from TS watch mode. So that, if one wants fast TS compilation, one must use watch mode.
So I would expect that Deno has a watch mode. But it doesn't. So how is TS compilation fast for Deno?
Note: I know Deno uses a V8 snapshot of tsc so that the tsc starts quickly, but for a large TS project startup time of tsc will be dwarfed by actual compilation time. So I'm not asking about the V8 snapshoting, I'm asking what other tricks Deno uses. Does it use a build daemon?
Upvotes: 1
Views: 957
Reputation: 1678
Deno caches on disk transpiled output from TypeScript and uses that on subsequent requests for modules if the local source file has not changed (or lack of a --reload
flag for remote modules).
As of Deno 0.2.8, the TypeScript is lazily instantiated when a TypeScript module needs to be transpiled. Deno transpiles module by module, instead of a whole project, and caches the results of each individual module. So when just making a change to a single file, only that module is transpiled.
Because of this single file approach it does mean that you can sometimes run into runtime errors that would have been caught by the TypeScript compiler. If you want to ensure that your programme is entirely consistent from a type perspective, using --recompile
will cause each module to be recompiled.
Adding watch functionality could be added, but that would be a feature request. There are significant challenges to dealing with such a feature though, because of the way the runtime environment works.
Upvotes: 5