8

我正在尝试将 IVY 添加到我的 Angular 7 beta 项目中。所以,我添加enableIvy: true到部分src/tsconfig.app.jsoncompilerOptions

但是当我运行时,ng build --prod --aot --output-hashing none我得到以下错误。

error TS5023: Unknown compiler option 'enableIvy'.

Error: error TS5023: Unknown compiler option 'enableIvy'.

    at AngularCompilerPlugin._setupOptions (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:112:19)
    at new AngularCompilerPlugin (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:61:14)
    at _createAotPlugin (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/typescript.js:41:12)
    at Object.getAotConfig (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/typescript.js:63:19)
    at BrowserBuilder.buildWebpackConfig (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/src/browser/index.js:81:37)
    at MergeMapSubscriber.rxjs_1.of.pipe.operators_1.concatMap [as project] (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/src/browser/index.js:31:38)
    at MergeMapSubscriber._tryNext (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/mergeMap.js:65:27)
    at MergeMapSubscriber._next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/mergeMap.js:55:18)
    at MergeMapSubscriber.Subscriber.next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:64:18)
    at TapSubscriber._next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/tap.js:62:26)
    at TapSubscriber.Subscriber.next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:64:18)
    at MergeMapSubscriber.notifyNext (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/mergeMap.js:84:26)
    at InnerSubscriber._next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/InnerSubscriber.js:25:21)
    at InnerSubscriber.Subscriber.next (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:64:18)
    at ForkJoinSubscriber.notifyComplete (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/observable/forkJoin.js:79:25)
    at InnerSubscriber._complete (/Users/k26686/aniruddh/develop/experiment/shepherd/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/InnerSubscriber.js:32:21)

任何人都解决了这个问题。

4

3 回答 3

15

尝试在enableIvy下面包含选项angularCompilerOptions

"angularCompilerOptions": {
   "enableIvy": true
}
于 2018-09-18T09:27:34.363 回答
13

compilerOptions并且angularCompilerOptionstsconfig.json中的两个独立属性。您需要添加"enableIvy": trueangularCompilerOptions不是compilerOptions

tsconfig.json:

{
  "compilerOptions": {
  ....
  },
  "angularCompilerOptions": {
    "enableIvy": true
  }
}
于 2019-04-27T15:53:37.277 回答
3

现在设置了正确的方法

"angularCompilerOptions": {
   "enableIvy": "ngtsc"
}

这与问题#23455有关

此提交添加了一个不依赖于全局分析的新编译器管道,称为“ngtsc”。通过运行 ngc 并将“enableIvy”设置为“ngtsc”来访问这个新的编译器。它重用了相同的初始化逻辑,但创建了一个新的 Program 实现,它不执行 AngularCompilerProgram 所做的全局级分析。它将成为生产常春藤编译器的基础。

于 2018-12-19T18:07:24.407 回答