microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
99.05k stars 12.29k forks source link

Package compiler as `dotnet tool` and publish on nuget #56851

Open lonix1 opened 6 months ago

lonix1 commented 6 months ago

🔍 Search Terms

dotnet tool nuget Microsoft.TypeScript.MSBuild

✅ Viability Checklist

⭐ Suggestion

TypeScript is already packaged as the Microsoft.TypeScript.MSBuild nuget, which internally is self-contained.

That is really smart and useful for .NET devs, except when building non-trivial apps.

Please allow us to use it as a dotnet tool as well. That would be even simpler than a msbuild auto-task, so the heavy lifting seems to have already been done.

📃 Motivating Example

It would be much more useful as a dotnet tool, as we could use it inside msbuild, or from the terminal, and in CI, etc.

💻 Use Cases

  1. What do you want to use this for? I want to use it manually inside of msbuild, instead of letting it do all the work magically. It would be easier to write msbuild tasks that work in a particular way in dev and in CI.

  2. What shortcomings exist with current approaches? The automatic and magic msbuild tasks are nice, but limited.

  3. What workarounds are you using in the meantime? Using node the normal way, just for tsc. That is not a problem in the node-world, but in .NET that is cumbersome and harder to maintain, especially for non-Node devs. The idea of packaging it as a nuget was brilliant, but needs to also be a dotnet tool.

MartinJohns commented 6 months ago

TypeScript is already packaged as the Microsoft.TypeScript.MSBuild nuget, which internally is completely self-contained, without a need for installting Node.

I don't think this is the case. The NuGet package just adds a target that calls NodeJS, but does not provide it, so NodeJS still needs to be installed. You're probably just using the NodeJS version that is installed with Visual Studio without knowing it.

lonix1 commented 6 months ago

I double checked and you are correct... on windows it uses an exe, but on linux/mac it needs node.

Nevertheless, a dotnet tool is still preferable for the reasons above - use in msbuild, use from cli, etc.