typescript 编译器包不包含依赖项

编程入门 行业动态 更新时间:2024-10-23 09:25:39
本文介绍了typescript 编译器包不包含依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试将我的 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 编译器包不包含依赖项

本文发布于:2023-07-14 21:49:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107244.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   不包含   typescript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!