从Angular 13开始,已经弃用了编译器模块,并且在将来的版本中将会删除。因此,如果您在Angular 13中使用编译器模块,将会收到以下警告:
WARNING in Deprecation warning: Usage of the deprecated Ivy compiler implementation when AOT is enabled. The new compiler will be available from v13 on.
要解决这个问题,您需要通过以下步骤更新代码:
例如:
"compilerOptions": { "enableIvy": true, ... }
import { IvyJitCompilerFactory } from '@angular/compiler';
@NgModule({ ... providers: [ { provide: JitCompilerFactory, useClass: IvyJitCompilerFactory } ] }) export class AppModule { }
这将使用新的编译器工厂。
通过这些步骤,您将能够将代码迁移到Angular 13,并解决弃用编译器模块的问题。