question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:37 (21 by maintainers)

github_iconTop GitHub Comments

67reactions
filipesilvacommented, Jun 7, 2019

A workaround for now is to run the following commands after you are already on Angular and CLI version 8:

ng update @angular/cli --from 7 --to 8 --migrate-only
ng update @angular/core --from 7 --to 8 --migrate-only
10reactions
EzyHowcommented, Jun 9, 2019

Following worked for me:

ng update @angular/cli --from 7 --to 8 --migrate-only
ng update @angular/core --from 7 --to 8 --migrate-only
ng update @angular/material --from 7 --to 8 --migrate-only

Before above, I tried running:

ng update @angular/cli
ng update @angular/core
ng update @angular/material

But these only updated package.json. Not updated @Viewchild(), loadChildren and material imports.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found