Note that there are some explanatory texts on larger screens.

plurals
  1. POGather reference dependency tree from TypeScript file
    text
    copied!<p><strong>Question:</strong></p> <p>Regarding compiling TypeScript code server-side, is there a way to get a list of all the reference paths either for a single .ts file - or better, the whole compilation (starting from a single .ts file)? In order, preferably.</p> <p>I'd prefer to use the existing parser if possible, rather than parsing the files with new code.</p> <p><strong>Context:</strong></p> <p>Since I don't think it exactly exists, I want to write:</p> <ol> <li>a server-side web user control that takes a .ts path and generates a cache-busting script tag pointing to</li> <li>an HttpHandler that compiles the requested .ts file ONCE at first request and then adds CacheDependencies to all the reference dependencies paths. When a file changes, the script-generating web user control updates it's cache-busting suffix of subsequent requests.</li> </ol> <p>so in Release Mode, <code>&lt;tsb:typescript root="app.ts" runat="server" /&gt;</code> yields</p> <pre><code>&lt;script type="text/javascript" src="app.ts?32490839"&gt;&lt;/script&gt; </code></pre> <p>where the delivered script is the on-demand, cached single-file script.</p> <p>And in Debug Mode the unmodified tag instead yields:</p> <pre><code>&lt;script type="text/javascript" src="dependency1.ts?32490839"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="dependency2.ts?32490839"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="app.ts?32490839"&gt;&lt;/script&gt; </code></pre> <p>As far as I've looked, this mode of operation is not supported by the TypeScript Visual Studio plugin nor any of the Optimizer bundlers. The bundlers do close to what I'm asking for, but they don't cache-bust and they don't single-file compile without annoying explicit bundling of the files.</p> <p>I don't mind any performance hit at the very first request while the scripts are compiled. Besides that, perhaps there's a really great reason that this setup shouldn't or can't exist. If this cannot or clearly should not be done, I'd appreciate answers in that vein as well.</p> <p>I've seen other questions on StackOverflow that dance around this desire in my interpretation, but nothing so explicit as this and none with relevant answers.</p> <p>Thanks!</p> <p>Also, is executing tsc.exe in a different process the best way for my HttpHandler to compile at runtime or is there a slick, safe, and simple way to do this in-process?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload