Skip to content

fix(migrations): handle import aliases to the same module name#63934

Closed
mattlewis92 wants to merge 1 commit intoangular:mainfrom
mattlewis92:fix-63913
Closed

fix(migrations): handle import aliases to the same module name#63934
mattlewis92 wants to merge 1 commit intoangular:mainfrom
mattlewis92:fix-63913

Conversation

@mattlewis92
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

If a module imports 2 modules with the same name but one with an alias, the aliased one is not added to the component imports array

e.g. when migrating this component:

import { Component, NgModule } from '@angular/core';
import { AnotherModule } from '../another/another';
import { AnotherModule as LegacyAnotherModule } from '../another/another-legacy';

@Component({
  selector: 'my-comp',
  template: '<another1 /> <another2 />',
  standalone: false
})
export class MyComponent {}

@NgModule({
  imports: [AnotherModule, LegacyAnotherModule],
  declarations: [MyComponent],
  exports: [MyComponent]
})
export class MyModule {}

The component imports array is set to:

imports: [AnotherModule]

Issue Number: #63913

What is the new behavior?

When migrating the example above, the component imports array is set to:

imports: [AnotherModule, LegacyAnotherModule]

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Fixes a bug in the standalone migration where 2 imported modules have the same class name but 1 is imported with an alias and would not be added to the component imports array when migrating

Fixes angular#63913
@pullapprove pullapprove bot requested a review from kirjs September 19, 2025 09:28
@angular-robot angular-robot bot added the area: migrations Issues related to `ng update`/`ng generate` migrations label Sep 19, 2025
@ngbot ngbot bot added this to the Backlog milestone Sep 19, 2025
Copy link
Copy Markdown
Member

@JeanMeche JeanMeche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this !

@JeanMeche JeanMeche removed the request for review from kirjs September 19, 2025 11:04
@JeanMeche JeanMeche added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Sep 19, 2025
@thePunderWoman
Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

thePunderWoman pushed a commit that referenced this pull request Sep 19, 2025
Fixes a bug in the standalone migration where 2 imported modules have the same class name but 1 is imported with an alias and would not be added to the component imports array when migrating

Fixes #63913

PR Close #63934
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: migrations Issues related to `ng update`/`ng generate` migrations target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants