【发布时间】:2017-03-11 14:35:09
【问题描述】:
使用以下打字稿和角度编译器配置:
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noEmitHelpers": true,
"skipDefaultLibCheck": true,
"strictNullChecks": false,
"outDir": "tmp"
},
"exclude": [
"node_modules",
"compiled",
"app/main.ts"
],
"angularCompilerOptions": {
"genDir": "compiled",
"skipMetadataEmit" : true
}
}
/compiled 目录仅包含 /node_modules/@angular,而缺少所需 ngfactory 文件的 /app 目录。编译以静默方式结束,没有错误也没有输出。
它在 Typescript 2.0 上工作得很好,但我想在针对 es5 时使用 2.1 来支持 async/await,从而消除使用 babel 的额外编译步骤。
[编辑]
这只发生在Typescript 2.1.0-dev.20160907 之后,也就是实现异步/等待支持的时候。我猜这是该版本中破坏ngc 的更改之一; 2.1.0-dev.20160906 仍然有效。
[编辑2]
如果有人尝试将ngc 与 typescript 2.1 一起使用,如果它适合您,您能否留下简短的评论?这至少可以告诉我问题是否与我的配置有关。
【问题讨论】:
-
我不是 Typescript 方面的专家,但我记得看到
outDir对 Angular 2 产生了奇怪的影响;你在tmp目录中看到了什么样的输出? -
tmp目录包含来自app的已编译(js + map)文件。没有outDir选项的行为相同,compiled没有任何应用程序文件,只有 node_modules。 -
昨天我在使用 Typescript 2.1 和 Angular 2.3.0 时遇到了同样的问题,但没有在我的 tsconfig.json 中指定
outDir。切换回 2.0.x Typescript 是可行的,所以据我所知,这不是 Angular 的错。 -
Jit 编译似乎工作正常。我认为问题在于 AoT 编译,具体可能是
ngc。
标签: angular typescript angular2-compiler