Skip to content

feat(ivy): implement listing lazy routes in ngtsc - #27697

Closed
gkalpak wants to merge 11 commits into
angular:masterfrom
gkalpak:ngtsc-routes
Closed

gkalpak wants to merge 11 commits into
angular:masterfrom
gkalpak:ngtsc-routes

Conversation

@gkalpak

@gkalpak gkalpak commented Dec 16, 2018 •

Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

  • Feature
  • Build related changes

What is the current behavior?

ngtsc does not support listLazyRoutes(), which the cli uses to split code into bundles.

Jira issue: FW-629

What is the new behavior?

ngtsc does support listing all lazy routes. It still does not support listing routes for a specific entry point (but I am not sure if it is necessary with Ivy - see "More information" below).

Does this PR introduce a breaking change?

  • Yes
  • No

More information

Listing lazy routes for specific entry points is not needed atm (but will probably be needed in the future). Created FW-860 to track that.

@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that 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 here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@gkalpak gkalpak added feature Label used to distinguish feature request from other issues state: WIP target: major This PR is targeted for the next major release comp: ivy labels Dec 16, 2018
@ngbot ngbot Bot added this to the needsTriage milestone Dec 16, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview 275069d at https://pr27697-275069d.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 9211cb1 at https://pr27697-9211cb1.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 2ac4ecc at https://pr27697-2ac4ecc.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 045885b at https://pr27697-045885b.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview bff43e9 at https://pr27697-bff43e9.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview cf559d2 at https://pr27697-cf559d2.ngbuilds.io/.

@gkalpak gkalpak changed the title WIP - feat(ivy): implement listing lazy routes in ngtsc WIP - feat(ivy): implement listing routes in ngtsc Dec 17, 2018
@gkalpak gkalpak changed the title WIP - feat(ivy): implement listing routes in ngtsc WIP - feat(ivy): implement listing lazy routes in ngtsc Dec 17, 2018
@mary-poppins

Copy link
Copy Markdown

You can preview bed15e5 at https://pr27697-bed15e5.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview ccabee3 at https://pr27697-ccabee3.ngbuilds.io/.

@gkalpak gkalpak mentioned this pull request Dec 17, 2018
11 of 13 tasks
@gkalpak gkalpak changed the title WIP - feat(ivy): implement listing lazy routes in ngtsc feat(ivy): implement listing lazy routes in ngtsc Dec 17, 2018
@gkalpak
gkalpak requested a review from alxhub December 18, 2018 07:55

@petebacondarwin petebacondarwin 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.

I couldn't find anything wrong with the code.
I feel that analyzer is a bit of an overloaded term; is it sensible to use it here? Do other handlers have analyzer services?
I wonder if we should get ngtsc and ngcc to use shared code for module resolution? Or perhaps their structures are enough different.
I think the code would hugely benefit from some documentation comments and even some unit tests.
Otherwise LGTM!!

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.

Can we document this enum and its members?

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.

You could simplify a lot of the code below if you made this class DynamicValue<R = {}>, right?

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.

+1 good idea.

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.

Can we document this class? Who uses it and why is it needed?

Also should be using it elsewhere in ngtsc/ngcc? There is definitely module resolution going on in ngcc...

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.

Added some docs. Looked at reusing this in ngcc and it doesnt seem to be a good fit (at least without a non-trivial refactoring, which feels out-of-scope for this PR).

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.

Do we care if the identifier has more than one #?

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.

Since this is only called with values of Route#loadChildren properties (for which having multiple # would be invalid), I think it is fine.

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.

What FFR stands for is not documented - I am guessing it is Foreign Function Reference?

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.

Close 😃
It is foreign function resolver, which can be used to statically resolve a call expression.
I'll add a comment and try to type it more explicitly 😃

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.

This feels more like a register... than a resolve... method??

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.

Or at least this method is actually doing two things, it is resolving the RouterEntryPoint and registering it so that it can be subsequently accessed via fromNgModule.

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.

Yes, it will register it if it is not already registered (but it feels like a side effect).
Open to name suggestions 😁

@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.

LGTM, pending Pete's comments :)

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.

Please add a comment with the name of the argument for which null is being passed here.

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.

+1 good idea.

@alxhub alxhub added cla: yes and removed cla: no labels Dec 19, 2018
@googlebot

Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@alxhub

alxhub commented Dec 19, 2018

Copy link
Copy Markdown
Member

alxhub and others added 10 commits January 21, 2019 18:28
…propriate

This makes the types (and intentions) more explicit and clear.
This commit introduces the NgModuleRouteAnalyzer & friends, which given
metadata about the NgModules in a program can extract the list of lazy
routes in the same format that the ngtools API uses.
This commit introduces a new mode for the NgtscTestEnvironment which
builds the NgtscProgram and then asks for the list of lazy routes,
instead of running the TS emit phase.
This commit uses the NgModuleRouteAnalyzer introduced previously to
implement listLazyRoutes() for NgtscProgram. Currently this implementation
is limited to listing routes globally and cannot list routes for a given lazy
module. Testing seems to indicate that the CLI uses the global form, but this
should be verified.

Jira issue: FW-629
@googlebot

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that 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 here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jan 22, 2019
@ngbot

ngbot Bot commented Jan 22, 2019

Copy link
Copy Markdown

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "cla/google" is failing
    pending missing required labels: cla: yes
    pending forbidden labels detected: cla: no
    pending status "google3" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@gkalpak

gkalpak commented Jan 22, 2019

Copy link
Copy Markdown
Member Author

merge-assistance:

@alxhub alxhub added cla: yes and removed cla: no labels Jan 22, 2019
@googlebot

Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@alxhub

alxhub commented Jan 22, 2019

Copy link
Copy Markdown
Member

And another presubmit

@alxhub alxhub closed this in 9e5016c Jan 22, 2019
alxhub pushed a commit that referenced this pull request Jan 22, 2019
…propriate (#27697)

This makes the types (and intentions) more explicit and clear.

PR Close #27697
alxhub added a commit that referenced this pull request Jan 22, 2019
This commit introduces the NgModuleRouteAnalyzer & friends, which given
metadata about the NgModules in a program can extract the list of lazy
routes in the same format that the ngtools API uses.

PR Close #27697
@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.

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 cla: yes feature Label used to distinguish feature request from other issues 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