【问题标题】:typescript compiler bundle doesn't contain dependenciestypescript 编译器包不包含依赖项
【发布时间】:2017-08-04 21:51:49
【问题描述】:

我尝试将我的 angular2 应用程序与带有 tsconfig.js 的 typescript 编译器捆绑在一起,如下所示:

{
  "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,但没有任何角度依赖性。它只包括我自己的组件和打字稿文件。知道如何告诉编译器将引用的依赖项也包含到包中吗?

【问题讨论】:

    标签: typescript systemjs


    【解决方案1】:

    你没有具体提到你想要捆绑的什么; Angular 2 框架本身,或其类型定义文件。我认为前者是正确的。

    TypeScript 编译器不会为您捆绑您的应用,它只会将 TS 代码编译为 JS。
    也许混淆在于outFile 选项,is stated 到:

    连接并将输出发送到单个文件 […]

    ...但仅适用于您自己的应用程序中的 TS 输入文件。

    为了在您的应用程序中包含 Angular 2 源文件,您必须使用 bundler,例如 webpack。

    【讨论】:

      猜你喜欢
      • 2013-04-21
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 2023-02-22
      • 2012-11-11
      • 1970-01-01
      相关资源
      最近更新 更多