我尝试将我的 angular2 应用程序与带有 tsconfig.js 的打字稿编译器捆绑在一起:
I try to bundle my angular2 application with the typescript compiler with a tsconfig.js like this:
{ "compilerOptions": { "target": "es5", "module": "system", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es2015", "dom" ], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true, "outFile": "bundle.js" } }它创建了一个 bundle.js 但没有任何角度依赖.它只包含我自己的组件和打字稿文件.知道如何告诉编译器将引用的依赖项也包含到包中吗?
It creates a bundle.js but without any angular-depenencies. It only includes my own components and typescript files. Any idea how I can tell the compiler to include the referenced dependencies as well into the bundle?
推荐答案您没有提到什么您想要捆绑;Angular 2 框架本身或其类型定义文件.我认为前者是正确的.
You didn't mention what exactly you want to bundle; the Angular 2 framework itself, or its type definition files only. I presume the former is correct.
TypeScript 编译器不会为您捆绑您的应用,它只会将 TS 代码编译为 JS.也许混淆在于 outFile 选项,它 声明:
The TypeScript compiler won't bundle your app for you, it will just compile TS code to JS. Perhaps the confusion lies in the outFile option, which is stated to:
连接输出到单个文件 […]
Concatenate and emit output to single file […]
…但仅适用于您自己的应用程序中的 TS 输入文件.
… but applies only to TS input files in your own application.
为了在您的应用程序中包含 Angular 2 源文件,您必须使用 bundler,例如 webpack.
In order to include the Angular 2 source files with your application, you'd have to use a bundler such as webpack.
更多推荐
typescript 编译器包不包含依赖项
发布评论