Repository navigation
Conversation
| } | ||
|
|
||
| fixmeIvy('FW-629: ngtsc lists lazy routes').it('should list lazy routes recursively', () => { | ||
| fit('should list lazy routes recursively', () => { |
There was a problem hiding this comment.
I know, I know 😃 (This is not really ready for review - sorry for the misleading label 😞)
78194fb to
0d0b1e4
Compare
64f8b97 to
80eb608
Compare
There was a problem hiding this comment.
ngtsc complained about non-existent component.
petebacondarwin
left a comment
There was a problem hiding this comment.
Awesome PR. Some really nice computation.
A few Qs and suggestions but looks good.
Do we need to worry about / test routes that point to files that are in a different source root folder?
There was a problem hiding this comment.
These toString() methods are really helpful when debugging and in errors. I accept that there is no real need for the abstract version since all Objects have this method defined already.
There was a problem hiding this comment.
Happy to bring that back then 😃
There was a problem hiding this comment.
I don't believe you need the as 'ngtsc' here.
There was a problem hiding this comment.
Without it, the type of the object ends up as {enabledIvy: false | string}, which TS complains is not assignable to 'ngtsc' | boolean | ....
There was a problem hiding this comment.
Really? That is not what I see. {enableIvy: ivyEnabled && 'ngtsc'} appears to be enough.
There was a problem hiding this comment.
Oh, you are right. Originally, I had it as a separate variable:
const overrideOptions = {enableIvy: ivyEnabled && 'ngtsc' as 'ngtsc'};
const options = testSupport.createCompilerOptions(overrideOptions);In that case, TS complains without the as 'ngtsc', but when using the object literal directly, it is not necessary 🎉
Good catch!
There was a problem hiding this comment.
Should this fixmeIvy be removed if this commit is fixing something to work with ivy?
There was a problem hiding this comment.
I removed it in a subsequent commit, because this commit (although enough to make routes work in cli projects) was not enough to fix the test.
There was a problem hiding this comment.
I think this error message should have a bit more context. Perhaps:
Resolution of relative paths to lazy routes is not supported.
There was a problem hiding this comment.
My initial intention was to keep this close to the old AotCompilerHost implementation, but I don't see any reason to 😁
I'll add more info to the error.
There was a problem hiding this comment.
I don't find defining such functions via fat arrows very readable. Although I accept that the terrible automated formatting is partly to blame.
This is what it would look like as a normal function:
function lazyRouteMatching(
route: string, fromModulePath: RegExp, fromModuleName: string, toModulePath: RegExp,
toModuleName: string) {
return {
route: route, module: jasmine.objectContaining(
{name: fromModuleName, filePath: jasmine.stringMatching(fromModulePath)}),
referencedModule: jasmine.objectContaining(
{name: toModuleName, filePath: jasmine.stringMatching(toModulePath)}),
}
as unknown as LazyRoute;
}There was a problem hiding this comment.
Feel free to turn off the clang-formatter and do a better job of making the body readable :)
There was a problem hiding this comment.
Given that this is testing "all" routes, should we not have more than one route in the test?
There was a problem hiding this comment.
Good point. I was just refactoring what was there before.
There was a problem hiding this comment.
Do you need to have components for the compilation to work? If not is this unnecessary noise in this test?
There was a problem hiding this comment.
This is to ensure that having other things than NgModules in the exports does not throw the RouteAnalyzer off.
I can split it out into a separate test.
There was a problem hiding this comment.
Nice comment, thanks!
There was a problem hiding this comment.
Should ignore and not throw? Is that the specified behaviour? I guess this would throw later if you tried to navigate to that route?
There was a problem hiding this comment.
Yeah, that's a good question. Not sure what it should do (but added a test for what it actually does right now).
I chose the current behavior (not to throw if it doesn't know about a lazy route's module), because that is somewhat similar to what would happen if listLazyRoutes() was called without an entry point: It would list all routes found in the know modules, but it would not complain if a lazy route points to an unknown module.
I can be convinced otherwise, though 😃
There was a problem hiding this comment.
I'm actually planning on doing that soon anyway, for all of the tests in it. Stay tuned!
There was a problem hiding this comment.
Feel free to turn off the clang-formatter and do a better job of making the body readable :)
…y routes This will make it easier to retrieve routes for specific entry points in `listLazyRoutes()` (which is necessary for CLI integration but not yet implemented).
…`ngtsc` Related: angular/angular-cli#13532 Jira issue: FW-860
…point in `ngtsc` I don't know of any use of this API with a project-root-relative path (i.e. the cli will always call it with an absolute path), but keeping the API backwards compatible just in case.
… entry point in `ngtsc`
80eb608 to
242976c
Compare
|
Addressed the feedback in Still need to decide #28542 (comment) is what we want. |
petebacondarwin
left a comment
There was a problem hiding this comment.
Great! I don't know what the answer to #28542 (comment) is though.
…`ngtsc` (#28542) Related: angular/angular-cli#13532 Jira issue: FW-860 PR Close #28542
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Docs have been added / updated (for bug fixes / features)PR Type
What is the current behavior?
ngtsc'slistLazyRoutes()does not support listing routes for a specific entry point.@angular/clicalls this API to get a list of lazy-loaded entry points (routes) so that the bundler can create separate bundles for each. Under certain circumstances (e.g.jitmode), the cli may need to list routes for a specific root entry point only.Jira issue: FW-860
What is the new behavior?
ngtsc'slistLazyRoutes()supports listing routes for a specific entry point.Does this PR introduce a breaking change?
Other information
Related: angular/angular-cli#13532