How to remove @NgModule, app.module.ts files after upgrading to Angular 14+

176 Views Asked by At

Before Angular 14, It was mandatory to add modules to organize applicaiton with component hierarcy. After upgradation, we can optimize our code by removing modules and add dependancies to component level. What steps we need to consider while optimizing code?

I have removed app.module.ts and updated main.ts. How about other module level changes?

1

There are 1 best solutions below

0
Fakhrul Hossain On

We have to update main.ts file. Instead of bootstrapModule, it need to call bootstapApplicaiton.

Changes in main.ts file

Upto Angular13: .bootstrapModule(AppModule)

Angular14+: bootstrapApplication(AppComponent, ...

Update component.ts file

add below directives in component level.

standalone: true, imports: [...], //Modules