ng update did not change my import statements
See original GitHub issueπ Bug report
Command (mark with an x)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [X] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
No, this behavior did not exist prior to 8.x
Description
ran ng update @angular/cli @angular/core
loadChildren import statements were not updated to new syntax
π¬ Minimal Reproduction
I havenβt dug into the migration code, but I have my routes in a app-routing.module.ts file:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
path: '',
pathMatch: 'full',
loadChildren: './home/home.module#HomeModule',
data: { depth: 0 },
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
export class AppRoutingModule {}
π₯ Exception or Error
No error, just old import pattern instead of new.
π Your Environment
I was on Angular 7.2.15 and this was part of the update process to 8.0.0.
Anything else relevant? Iβm wondering if the migration code is targeting a certain file or something else that would have excluded this file from being updated to the new import pattern.
Hereβs the last bit from the ng update command:
** Executing migrations for package '@angular/core' **
------ Static Query Migration ------
With Angular version 8, developers need to
explicitly specify the timing of ViewChild and
ContentChild queries. Read more about this here:
https://v8.angular.io/guide/static-query-migration
------------------------------------------------
UPDATE src/app/search/search.component.ts (2049 bytes)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:37 (21 by maintainers)
Top Results From Across the Web
Angular cannot import module after upgrading to version 8
I am updating angular version 7 to 8. using ng update @angular/cli @angular/core command but angular is not automatically changing routeΒ ...
Read more >ng update - Angular
Perform a basic update to the current stable release of the core framework and CLI by running the following command. content_copy ng update...
Read more >Angular 8 Upgrade: Using Ng-Update & Angular CLI v8
ng update @angular/material. This command will update the package and automatically change the imports statements of your Angular MaterialΒ ...
Read more >Automatically Updating Angular Modules With Schematics ...
This function comes in handy for generating the import statement pointing from the module file to the file with the component to register....
Read more >Ninja Squad: Le Blog
The NgForOf directive is now aliased as NgFor which makes it simpler to import it in your standalone components, as you previously had...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

A workaround for now is to run the following commands after you are already on Angular and CLI version 8:
Following worked for me:
Before above, I tried running:
But these only updated package.json. Not updated @Viewchild(), loadChildren and material imports.