Skip to content

refactor(router): remove support for loadChildren string syntax - #43591

Closed
JoostK wants to merge 6 commits into
angular:masterfrom
JoostK:remove-loadchildren-string-all-in
Closed

JoostK wants to merge 6 commits into
angular:masterfrom
JoostK:remove-loadchildren-string-all-in

Conversation

@JoostK

@JoostK JoostK commented Sep 25, 2021

Copy link
Copy Markdown
Member

This commit removes the ability to configure lazy routes using a string
for loadChildren, together with the supporting classes to load an
NgModuleFactory at runtime.

BREAKING CHANGE:

It is no longer possible to use Route.loadChildren using a string
value. The following supporting classes were removed from
@angular/core:

  • NgModuleFactoryLoader
  • SystemJsNgModuleFactoryLoader

The @angular/router package no longer exports these symbols:

  • SpyNgModuleFactoryLoader
  • DeprecatedLoadChildren

The signature of the setupTestingRouter function from
@angular/core/testing has been changed to drop its NgModuleFactoryLoader
parameter, as an argument for that parameter can no longer be created.


This PR is an alternative to #43575 and removes NgModuleFactoryLoader and the string type for Route.loadChildren altogether.

@JoostK JoostK added breaking changes area: router area: core Issues related to the framework runtime target: major This PR is targeted for the next major release labels Sep 25, 2021
@google-cla

google-cla Bot commented Sep 25, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@ngbot ngbot Bot modified the milestone: Backlog Sep 25, 2021
@google-cla google-cla Bot added the cla: no label Sep 25, 2021
@JoostK
JoostK force-pushed the remove-loadchildren-string-all-in branch from d484e31 to 29ea269 Compare September 25, 2021 20:01
@google-cla

google-cla Bot commented Sep 25, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@JoostK
JoostK force-pushed the remove-loadchildren-string-all-in branch from 29ea269 to 7c44826 Compare September 25, 2021 21:00
@google-cla

google-cla Bot commented Sep 25, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@JoostK
JoostK force-pushed the remove-loadchildren-string-all-in branch from 7c44826 to ddbe652 Compare September 25, 2021 21:38
@google-cla

google-cla Bot commented Sep 25, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@JoostK
JoostK force-pushed the remove-loadchildren-string-all-in branch from ddbe652 to e2c84c2 Compare September 25, 2021 21:58
@google-cla

google-cla Bot commented Sep 25, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@JoostK
JoostK marked this pull request as ready for review September 25, 2021 22:30
@pullapprove
pullapprove Bot requested review from IgorMinar and atscott September 25, 2021 22:31
@JoostK JoostK added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Sep 25, 2021
Comment thread packages/compiler-cli/test/ngc_spec.ts Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These tests are retained as special handling in the VE compiler was not removed, as it's not currently worth the risk/effort to change VE's behavior.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is technically a breaking change (and mentioned in the commit message) to a signature that was not marked as deprecated, but I don't see a different way of achieving this. Since this is test-only code it is unlikely to be called from a library, so I'd consider this an acceptable break.

@atscott This particular change is not accounted for in the fixup commit that removes NgModuleFactoryLoader. Any g3 usages need to be cleaned up separately (or we'd have to extend the patch to undo this change and create an intermediate Injector to provide the given NgModuleFactoryLoader)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As long as g3 still uses loadChildren: string, we'll still need this because the tests need a way to stub the loader.

Ah, I see what you did. I don't think this should be an issue.

Comment thread packages/compiler-cli/integrationtest/ngtools_src/feature2/feature2.module.ts Outdated
Comment thread aio/content/guide/deprecations.md Outdated
Comment thread packages/core/src/linker/ng_module_factory_loader.ts Outdated
@google-cla

google-cla Bot commented Sep 27, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

The string syntax for `loadChildren` has been deprecated and is being
removed, so this commit refactors the examples to the new syntax.
This commit removes the ability to configure lazy routes using a string
for `loadChildren`, together with the supporting classes to load an
`NgModuleFactory` at runtime.

BREAKING CHANGE:

It is no longer possible to use `Route.loadChildren` using a string
value. The following supporting classes were removed from
`@angular/core`:

- `NgModuleFactoryLoader`
- `SystemJsNgModuleFactoryLoader`

The `@angular/router` package no longer exports these symbols:

- `SpyNgModuleFactoryLoader`
- `DeprecatedLoadChildren`

The signature of the `setupTestingRouter` function from
`@angular/core/testing` has been changed to drop its `NgModuleFactoryLoader`
parameter, as an argument for that parameter can no longer be created.
Now that `Route.loadChildren` no longer accepts a string, there is no
need for tooling to find all string-based `loadChildren` to setup lazy
imports for them. As a result, the `listLazyRoutes` operation that
enumerates all string-based `loadChildren` occurrences is no longer
needed and is therefore removed from the compiler.

The `listLazyRoutes` API remains on the `Program` interface to avoid
breaking external tools that may be using this method, but those tools
should ultimately move away from using this API.
@atscott
atscott force-pushed the remove-loadchildren-string-all-in branch from 4e54706 to 04fb369 Compare September 29, 2021 20:55
@alxhub alxhub added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 29, 2021

@alxhub alxhub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

reviewed-for: public-api
reviewed-for: size-tracking

@jessicajaniuk jessicajaniuk left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🍪
reviewed-for: public-api, size-tracking

@alxhub

alxhub commented Sep 29, 2021

Copy link
Copy Markdown
Member

Pull Approve is confused...

@alxhub alxhub added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Sep 29, 2021
@alxhub alxhub closed this in 05c08ca Sep 29, 2021
alxhub pushed a commit that referenced this pull request Sep 29, 2021
…3591)

This commit removes the ability to configure lazy routes using a string
for `loadChildren`, together with the supporting classes to load an
`NgModuleFactory` at runtime.

BREAKING CHANGE:

It is no longer possible to use `Route.loadChildren` using a string
value. The following supporting classes were removed from
`@angular/core`:

- `NgModuleFactoryLoader`
- `SystemJsNgModuleFactoryLoader`

The `@angular/router` package no longer exports these symbols:

- `SpyNgModuleFactoryLoader`
- `DeprecatedLoadChildren`

The signature of the `setupTestingRouter` function from
`@angular/core/testing` has been changed to drop its `NgModuleFactoryLoader`
parameter, as an argument for that parameter can no longer be created.

PR Close #43591
alxhub pushed a commit that referenced this pull request Sep 29, 2021
Now that `Route.loadChildren` no longer accepts a string, there is no
need for tooling to find all string-based `loadChildren` to setup lazy
imports for them. As a result, the `listLazyRoutes` operation that
enumerates all string-based `loadChildren` occurrences is no longer
needed and is therefore removed from the compiler.

The `listLazyRoutes` API remains on the `Program` interface to avoid
breaking external tools that may be using this method, but those tools
should ultimately move away from using this API.

PR Close #43591
@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 30, 2021
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: core Issues related to the framework runtime area: router breaking changes cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants