Angular 如何处理 NgModule.imports 中未使用的模块?

问题描述 投票:0回答:0
import { NgModule } from '@angular/core'

@NgModule({
  imports: [
    AModule,
    BModule,
    CModule,
    DModule,
    EModule,
    FModule,
    GModule,
    IModule,
    JModule,
    KModule,
    // ...
    JustModule,
  ],
  declarations: [ImportComponent],
})
export class ImportModule {}

比如我在

ImportModule
中导入了N+个模块,但最后只有
JustModule
ImportComponent
使用,其他模块会不会被Angular的编译器去掉?

Angular 的版本是

v15.2.0
.

我试着在

development
环境下查看编译后的产品,发现连不用的模块都被webpack导入了(
require
)。不知道
production
环境是什么情况

angular webpack frameworks jit aot
© www.soinside.com 2019 - 2024. All rights reserved.