I know it is possible to compile all your typescript files to one file using the "outFile": "../../built/local/tsc.js" compiler option. But is it possible to just use that to compile every typescript file in a specific directory and compile the rest the default way?
1 Answer
yes, you can, but to make it work properly you will have met some requiremenst,
let's assume you have src folder and src/sub folder which you want to build it in one .js file
src/subfolder should haveindex.tsfile, which should have named exports for each of its public interface (methods, consts, enums, etc.)all other files in
srcfolder (outside ofsubfolder), should import ONLY fromsub/index.tsin
srcfolder should be 2tscofigs- one for
src/sub(tsconfig.sub.jsonwhich has to import
./sub/index.tsand"outFile": "../dist/sub.js") - second for
src(tsconfig.json, which should explicetelyexcludesrc/sub)
- one for
- Order of build could make a difference
tsconfig.jsonfiles and specify different arootDirin each, you can also useexcludeandincludeas well as various combinations of configuration inheritance and command line arguments to accomplish this. Can you explain a bit more about what you want to achieve specifically? There are many ways to skin this cat.