[英]How to compile down typescript while using personal and external modules?
I have a typescript project where I want to supplement my code with an imported library that was downloaded from npm. 我有一个打字稿项目,我想在其中添加从npm下载的导入库来补充代码。 How can I compile all of this down to a single javascript file that includes all of my code along with the node library it depends on?
如何将所有这些编译为单个javascript文件,其中包括我的所有代码以及它所依赖的节点库?
Basically: 基本上:
compiles file1.ts
+ file2.ts
+ external library
into a single build.js
file 将
file1.ts
+ file2.ts
+ external library
编译为单个build.js
文件
This is referred to as "bundling"; 这称为“捆绑”; TypeScript does not provide bundling for compilations that use module constructs like
import
, export
, or require
. TypeScript不为使用诸如
import
, export
或require
类的模块构造的编译提供捆绑。 You'll need to use a tool, such as webpack or rollup, to combine multiple modules into a single file. 您将需要使用诸如webpack或汇总工具之类的工具,将多个模块组合到一个文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.