title: How to combine TypeScript code and JS libraries into one file with source maps?
body: <p>I can successfully compile my TypeScript project into a single JS file with source maps using something like this:</p>
  
  <pre><code>tsc --sourcemap --out app.js app.ts
  </code></pre>
  
  <p>I can also successfully minify that output using UglifyJS, while keeping source maps intact:</p>
  
  <pre><code>uglifyjs app.js --source-map app.js.map --in-source-map app.js.map -o app.js
  </code></pre>
  
  <p>However, I would like to go slightly further. I want to combine my compiled TypeScript code (<code>app.js</code>) with a couple third-party JS libraries into a single minified file that maintains source maps pointing back to the original TypeScript (for my code) or JavaScript (for the third-party libraries).</p>
  
  <p>I tried something like this, basically just adding a JS library file to the input to UglifyJS:</p>
  
  <pre><code>uglifyjs app.js lib/javascript-library.js --source-map app.js.map --in-source-map app.js.map -o app.js
  </code></pre>
  
  <p>Unfortunately, that doesn't seem to work. It does successfully combine everything into one file, and the source maps for the TypeScript code seem to be preserved. But when I put an error in <code>lib/javascript-library.js</code>, the JS console in my browser (using source maps) says the error is in one of my TypeScript files, which is obviously wrong.</p>
  
  <p>I am a TypeScript newb and I can't imagine I'm the first one to want to combine TS output with random JS libraries in a single minified file with source maps, but I can't find anyone talking about it. So maybe my approach is just completely wrong?</p>