简体   繁体   中英

Bundle TypeScript with external JS files (e.g. node_modules)

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

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM