Description
When I build a Visual Studio project that has multiple .ts files, the build system invokes a single tsc.exe compiler using syntax similar to the following:
C:[,,,,]\tsc.exe --sourcemap --target ES5 --noEmitOnError --locale en-US "C:[......]\file1.ts" "C:[......]\file2.ts" "C:[......]\file3.ts"
Notice that the three .ts files are all included in a single invocation of the compiler.
I would like to configure the Visual Studio project so that it invokes tsc.exe once for each .ts file.
That way, the resulting .js file will contain not only contents of the corresponding .ts file, but also the compiled contents from any .ts files it references using the /// references syntax.
Then I would only mark few of the .ts files with the TypeScriptCompile BuildAction. The other .ts files that are meant to be "included" will have their BuildAction NOT be set to TypeScriptCompile.
In addition, I need a way to mark a .ts file both "TypeScriptCompile" and "Embeded Resource". The reason is because I am using a self-hosting service with EmbeddedResourceFileSystem from Microsoft.Owin.FileSystems. I need the .ts file to be embedded so that it is served by the self-hosting web server -- that way it can be used for debugging from the browser when source-maps reference it. But it also has to be marked as "TypeScriptCompile" so that it actually compiles.
As a work-around, I'm doing the following steps:
- I removed the Microsoft.TypeScript.targets from the .csproj file. (the .csproj file didn't have it to begin with. I had to add it there. See http://stackoverflow.com/questions/33374040/how-do-i-enable-the-typescript-tab-of-a-visual-studio-project-thats-a-console-o/33374041#33374041 )
- put "library" style .ts files in a "mod" folder (stands for modules), but they're really separate namespaces (internal modules)
- put all of my "app" style .ts files, the ones I want to compile, into a main root folder. These .ts files may reference one or more .ts files from the mod folder using /// references syntax.
- I have a batch file where for every .ts file in the main root folder it invokes the tsc compiler and generates a output .js file which gets placed in an "output" folder. Those are the actual .js files that are referenced from html.
All of the .ts files and .js files in the output folder, along with .map files, are marked as "Embedded" so that they get served by the self-hosting server using EmbeddedResourceFileSystem.
I also added an uglifyjs2 step in there, but I won't discuss that here 'cause that's just an extra optimization step that it's strictly necessary.
Suffice it to say, I'm not using the Visual Studio TypeScript integration at all, which is unfortunate.
Do you guys think that what I'm trying to do is main-stream enough where it should be supported natively?