1

Is there a way to setup a "BeforeBuild" step that compiles each TypeScript file to its own Javascript file in a specific directory? For instance, I would like all TypeScript files to compile to a individual Javascript files in the '\tsbuild' directory in the solution.

Right now the compiler is combining all of the TypeScript files into one Javascript file in a specified directory - which looks like this:

  <Target Name="BeforeBuild">
    <Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot; --out @(TypeScriptCompile ->'&quot;$(ProjectDir)tsbuild\buildall.js&quot; &quot;%(fullpath)&quot; ', ' ')" />
  </Target>

Then, once they are in one directory, the goal is to configure the Bundle Configuration to pick them up and minify them during release. The other purpose is to help troubleshooting during development.

2
  • isn't the VS typescript extensions already doing this? Commented Jan 18, 2013 at 16:40
  • Yes and No...It compiles it in the same directory where the file resides. I want it to compile it to a central location. Commented Jan 18, 2013 at 17:10

2 Answers 2

3

Once 0.8.2.0 is released (soon!) you'll be able to pass a directory to --out to get the desired behavior. For now, there isn't a particularly elegant way to do this.

Sign up to request clarification or add additional context in comments.

2 Comments

Will the comment preservation problems be fixed in 0.8.2.0? Or any rough idea of how long that might take to fix? I'm sure its low on the priority list.
Comment preservation will get a bit better in 0.8.2.0, but when the new parser comes online in a later release, it will be vastly improved (our goal is that vanilla JS would compile with identical formatting/comments).
2

With the release of TypeScript 0.8.2, there is some build changes that I made that I now have it working the way I want.

For more information the Compile and Save, check out: http://typescript.codeplex.com/wikipage?title=Compile-on-Save

First I modified my *.csproj, adding:

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptIncludeComments>false</TypeScriptIncludeComments>
    <TypeScriptSourceMap>false</TypeScriptSourceMap>
  </PropertyGroup>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />

Then, I created a post build step that copies my files using this Post https://stackoverflow.com/a/585188/1220302

Adding this to a post build

for /R "$(ProjectDir)modules\" %%f in (*.js, *.map) do copy %%f "$(ProjectDir)build\"

I hope that helps someone.. =)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.