问题
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