Skip to content

refactor(router): avoid using deprecated Compiler symbol in Router #44194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

AndrewKushnir
Copy link
Contributor

The Compiler symbol was deprecated in v13 as a part of the factory-less cleanup in public APIs. This commit updates the logic inside of the Router package to avoid using it in favor of replacement API (the createNgModuleRef function).

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added state: WIP refactoring Issue that involves refactoring or code-cleanup area: router target: patch This PR is targeted for the next patch release labels Nov 17, 2021
@google-cla google-cla bot added the cla: yes label Nov 17, 2021
@ngbot ngbot bot modified the milestone: Backlog Nov 17, 2021
} else {
return from(this.compiler.compileModuleAsync(t));
}
return isNgModuleFactory(t) ? of(t) : from(Promise.resolve(t));
Copy link
Member

Choose a reason for hiding this comment

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

Could we omit the Promise.resolve or is the additional microtick load-bearing, e.g. for tests? I don't think this code path is necessarily async now that we don't need to call into the async compiler anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to avoid any diff from the execution order perspective. Still, there are few CI failures that I'll need to investigate more and I will take this comment into account as well and will factor the code more if this is not load-bearing (as you mentioned).

@@ -595,7 +596,7 @@ export class Router {
this.rawUrlTree = this.currentUrlTree;
this.browserUrlTree = this.currentUrlTree;

this.configLoader = new RouterConfigLoader(injector, compiler, onLoadStart, onLoadEnd);
this.configLoader = new RouterConfigLoader(onLoadStart, onLoadEnd);
Copy link
Member

Choose a reason for hiding this comment

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

Heads up that the injector constructor parameter is depended upon by a g3 patch, so you may want to keep it in the source code to keep the impact of the patch small.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comment! Yeah, @atscott also mentioned that (offline), I will bring it back and add some comments in the code (it wasn't clear to me why we have an unused argument :)).

The `Compiler` symbol was deprecated in v13 as a part of the factory-less cleanup in public APIs. This commit updates the logic inside of the Router package to avoid using it in favor of replacement API (the `createNgModuleRef` function).
constructor(
private rootComponentType: Type<any>|null, private urlSerializer: UrlSerializer,
private rootContexts: ChildrenOutletContexts, private location: Location, injector: Injector,
// Note: the `compiler` argument is unused, but dropping it would be a breaking change.
// TODO: remove the `compiler` argument in the next major release (v14).
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to be merged before v14?

@angular-automatic-lock-bot
Copy link

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 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: router cla: yes refactoring Issue that involves refactoring or code-cleanup state: WIP target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants