-
Notifications
You must be signed in to change notification settings - Fork 143
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
Resolve "nested layout" components #1596
Resolve "nested layout" components #1596
Conversation
@@ -565,6 +565,7 @@ export class Resolver { | |||
|
|||
private *componentJSCandidates(inPackageName: string) { | |||
yield { prefix: '/components/', suffix: '' }; | |||
yield { prefix: '/components/', suffix: '/index' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I added a similar line to the componentTemplateCandidates
generator method I ran into an issue with the v2 addon component. Something about not being allowed to call setComponentTemplate
twice. My guess is that the v2 component is resolved twice in that scenario, since the extensions logic checks for both .js and .hbs files.
I haven't dug deeper to find the origins of the current setup. Adding it only here made the tests pass and I noticed yield { prefix: '/components/', suffix: '' };
wasn't added to componentTemplateCandidates
either, which might be because of similar reasons?
This scenario tests that "nested layout" components work as expected under the "optimized" Embroider preset.
It seems these were no longer being resolved properly, resulting in error messages like this: > Module not found: Error: Can't resolve '#embroider_compat/components/name-of-nested-layout-component' in 'snip'
0047b7d
to
07aaa06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new scenario adds a lot of extra CI jobs. Should I try to fit it in another scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please. If this fix is entirely in module-resolver.ts
it can get tested in core-resolve-test.ts
.
Thanks for working on this. I was guessing the fix for this would actually be at a slightly different spot. But I haven't dug in myself yet, so your solution may also be right. Is the problematic case the one where If the problematic case happens only inside I was also suspecting the problem could be in |
As far as I can see, it's the For example, in the tests I added here it looks for
Yea, I originally planned to do it like that, but then I saw that the In any case, it's probably going to take me a while to grasp the logic we're dealing with here, so no hard feelings if you would rather look into it yourself to find the real underlying issue 😄. |
@Windvis If you happen to need a strict mode test (as you mentioned in your previous PR), you can use this draft as a pattern, except enable the strict mode for an individual test case. |
I don't fully understand why this would be the correct place to fix this bug. We can use the test from here to debug it. |
Closing since I won't have the time to look into this again and it wasn't the correct fix anyways. |
This adds a new (failing) "nested-layout-components" scenario and the fix for it in a second commit.
Supersedes #1587 since it's not only a v2 addon issue.