Fix nested index route imports - #312
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
Confirmed this fixes the case in #311 — I applied it to a clean There's a closely related case a few lines up that I think it misses, though. When the Route::get('/albums/recent', fn () => 'ok')->name('albums.index.recent');
$imports = $childKeys->filter(fn ($_, $key) => $key !== 'index')->map(...)which drops the import entirely while // routes/albums/index.ts
const albums = {
index: Object.assign(index, index),
}
export default albums
I verified this against your branch specifically — with this PR applied, The filter just needs to stop dropping an $imports = $childKeys->filter(fn ($_, $key) => $key !== 'index' || $keysWithGrandkids->has($key))->map(...)with the same One other thought, take it or leave it: asserting on the generated import string proves the path changed, but not that the helper actually resolves — expect(photos.index.window().url).toBe("/photos/window"); |
|
Thanks @imanimen for checking the second case. I reviewed #317: it covers the populated-parent branch fixed here, also handles For the maintainers: would you prefer #317 to carry the complete fix for #311, with this PR closed in its favor, or would you like the remaining case addressed here? I'm happy to defer to #317 and will hold off on overlapping changes while you choose. |
|
Thanks for the detailed reproducer. I reviewed #317 and confirmed it covers this PR's To avoid duplicating the same source change, I won't push a competing expansion here while both PRs are open. I'm happy for the maintainers to choose #317 as the complete fix and close this PR, or I can update #312 if they prefer to keep the issue-linked branch. Either way, #317 should receive credit for identifying and covering the missing branch. |
|
Thank you for this PR! I merged #317 already (just got there first) so looks like this is taken care of. |
Closes #311
Summary
indexfrom its nested index barrel./index/indexinstead of self-importing./indexphotos.indextogether withphotos.index.windowRoot cause
When both route names exist, the generated
photos/index.tsbarrel shares a path with the leaf route. Importing./indextherefore resolves back to the current module and silently drops the nested route helper.User impact
Nested route helpers remain available to TypeScript and bundlers without changing generated imports for other route names.
Validation
vendor/bin/phpunit --filter PruneStaleFilesTest- 7 passed, 30 assertionsgit diff --check- passedRepository-wide formatting still reports pre-existing CRLF/style drift outside this focused change.
AI disclosure
This change was prepared with OpenAI Codex assistance and reviewed and validated locally by the contributor.