javascript – 使用外部JS文件捆绑TypeScript(例如node_modules)

我可以成功地将我的Typescript项目捆绑在一起并使用例如单个文件保存.

tsc --outFile "build/bundle.js"

但是,此文件仅包含Typescript文件,并且不包含“node_modules”目录中包含的任何文件,例如jQuery.如果我尝试执行捆绑包,我只会收到无法找到文件的错误.

如何将我的Typescript所依赖的“node_modules”文件添加到同一个捆绑包文件中?打字稿显然知道文件的位置,因为路径正确.

我正在使用SystemJS在浏览器中加载我的项目.我承认我很困惑我是怎么想加载模块和捆绑(我可以使用SystemJS捆绑器??)而不理解为什么有这么多路径来做这件事.

最佳答案 我在
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.

或者,您可以查看SystemJS Build Tool.

点赞