typescript compiler bundle doesn't contain dependencies

青春壹個敷衍的年華 提交于 2019-12-25 09:01:24

问题


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"
  }
}

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?


回答1:


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.

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 […]

… but applies only to TS input files in your own application.

In order to include the Angular 2 source files with your application, you'd have to use a bundler such as webpack.



来源:https://stackoverflow.com/questions/42788059/typescript-compiler-bundle-doesnt-contain-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!