4

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
  • 1
    You can create separate tsconfig.json files and specify different a rootDir in each, you can also use exclude and include as 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. Commented Sep 14, 2017 at 20:48

1 Answer 1

2
+50

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

  1. src/sub folder should have index.ts file, which should have named exports for each of its public interface (methods, consts, enums, etc.)

  2. all other files in src folder (outside of sub folder), should import ONLY from sub/index.ts

  3. in src folder should be 2 tscofigs

    • one for src/sub (tsconfig.sub.json which has to import
      ./sub/index.ts and "outFile": "../dist/sub.js")
    • second for src (tsconfig.json, which should explicetely exclude src/sub)
  4. Order of build could make a difference
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.