13

I can successfully bundle together my Typescript project and save it as a single file using e.g.

tsc --outFile "build/bundle.js"

However, this file only contains the Typescript files and none of the files it includes from the "node_modules" directory such as jQuery. If I try to execute the bundle, I'll just get errors the files cannot be found.

How can I add the "node_modules" files that my Typescript depends on to the same single bundle file? Typescript obviously knows where the files are as it has the paths correct.

I'm using SystemJS to load my project in the browser. I'll admit I'm very confused how I'm suppose to go about loading modules and bundling (I could use a SystemJS bundler??) and not understanding why there are so many paths to doing this.

fstr
  • 900
  • 3
  • 10
  • 31

1 Answers1

3

I found the following in the docs:

Specifying --outFile in conjunction with --module amd or --module system will concatenate all modules in the compilation into a single output file containing multiple module closures.

Alternatively, you can check out the SystemJS Build Tool.

Remo H. Jansen
  • 23,172
  • 11
  • 70
  • 93
  • The module setting is read from my tsconfig.json file (module is set to system) so I'm already doing this step. – fstr Dec 06 '16 at 00:43
  • Are you using `$ tsc -p tsconfig.json` or `$ tsc --outFile "build/bundle.js"` ? – Remo H. Jansen Dec 06 '16 at 00:50
  • I've tried both and they both produce the same results. Should my tsconfig have something special in it to bundle in the node_modules are well? – fstr Dec 06 '16 at 01:05
  • Can you please update your answer and include the content of your `tsconfig.json`? – Remo H. Jansen Dec 06 '16 at 01:48
  • 9
    I know this answer is old from 2016. But it didn't work. It seems the inclusion of node modules was actually a bug. https://github.com/Microsoft/TypeScript/issues/13414 – Kenji Noguchi Jul 11 '18 at 17:11