Logotype this builder I have provided is doing just that. By specifying input folder or separate files and one output file (.ts or .js) it generates one single merged file.
It reads all .ts files, fixes reference and import paths and writes all the code into one concatenated file (type check is available on every input file before concat).
It does same as .ts and after concatenation compiles the .ts file to .js.
I have following build structure for my temper project:
/builds: core.json, temper.json, utility.json (all build scripts)
/cache: cached builds
/lib: compiled js files
/src: concatenated core.ts and utility.ts files
/src/core: source core .ts files
/src/utility: source utility .ts files
/tsb.json (build script which is linked to temper.json, usually executes /lib/...js file after compilation when needed)
links: "builds/utility.json", "builds/core.json"
input: "src/*.ts" (all concatenated files inside src)
input: "src/core" (all files recursively in folder)
input: "src/utility" (all files recursively in folder)
Note that core.ts is dependent on utility.ts and it imports concatenated /src/utility.ts file to access its classes.
Take a look of this example and you will get the idea:
Documentation is coming soon and many improvements and new features which will allow your projects to copy .d.ts files into your project fixing its paths (some things may change until I publish it on npm, on git I will create additional branches for further
You mentioned that you are using external modules and step 2 you are adding export prefix (external modules should have that already?).
Though it would be nice that tsc would supported step 1 out of the box. Keep in mind that module.exports support is coming which will allow you to export your classes directly but I think that concatenation should still be there.