0

I want to compile a subset of my .ts files into a single .js file. There is a question that addresses how to compile everything into a single .js file, but I just need a subset.

I've looked around tsconfig.json, but didn't see anything obvious. Is there a way to do, preferably from the IDE (Visual Studio).

AngryHacker
  • 59,598
  • 102
  • 325
  • 594
  • Looking at compiler options, it seems like you can create a rootDir, where you specify each subset, in that subset only imports are allowed similar to https://medium.com/@balramchavan/smarter-way-to-organize-import-statements-using-index-ts-file-s-in-angular-c685e9d645b7, then in your outdir, you would get a set of ts files, which would get the preferred result – Pavlo Apr 10 '19 at 21:12

1 Answers1

1

There is the outFile argument which is mentioned by the question you referenced but, as you state, it will compile everything into one file. You could create a second tsconfig.json file (named tsconfig.subset.json or something) which uses the includes/excludes options to specify only the files you want but if any of the included files references any of the excluded files you will get an exception (e.g. the specific files must be self contained).

If you have a single file which you can use as an entry point that references only the subset of files you want bundled up you could use rollup or webpack.

Otherwise, if you just want to specify some specific collection of files that aren't really self contained I do not know any tools that do that.

Pace
  • 41,875
  • 13
  • 113
  • 156