Reference Hell

Topics: General
Sep 18, 2013 at 1:28 PM
Based on responses by the development team, TSC won't organize the dependencies automatically, so the only way to compile to single files correctly is to add a <references /> clause for each file in the correct order.

I believe I'm experiencing what I'd call a "reference hell". Trying to keep all references in order without using a global "references.ts" seems to be completely unmanageable.

I have some "components" folder, similar to how "Controls" are in win/web forms. In a page, I'd like to have access to all components and just build the page, but instead I need to keep adding a reference for each component I use in each page because adding a global "references" makes the output out of order eventually.

This is leading to to pages with things like 50 references and growing.

At the end I just gave up on using TSC for single file output, and have added grunt and batch scripts to do this.

Is there anyone else experiencing this problem? Have anyone tried to create single-file output without global references? Are there better solutions?

Thanks,
Natan
Sep 18, 2013 at 4:23 PM
Compiling the .ts files to .js files and then running the results through RequireJS to create a single file should work.

http://requirejs.org/docs/optimization.html
Sep 19, 2013 at 3:17 PM
Hi Dan_s,

In this respect, grunt can do that as well.
I guess the only solution then is to do this kind of thing, running a post processor outside VS.