Commit 043c4af
Fix barrel self-import when a route name is both a leaf and a prefix … (#317)
* Fix barrel self-import when a route name is both a leaf and a prefix of "index"
A barrel child named "index" is written to "index/index.ts", but the
generated import referenced "./index". Every resolver prefers the sibling
"index.ts", so the barrel imported itself.
With `photos.index` and `photos.index.window`, `photos/index.ts` emitted
`import index<hash> from './index'`, producing TS7022 and TS2303 under tsc.
Bundlers accepted it silently because `Object.assign(index, undefined)` is a
no-op, so `photos.index.window` was dropped with no warning.
When the "index" prefix has no leaf route of its own, such as
`albums.index.recent`, the previous `$key !== 'index'` filter removed the
import altogether while still emitting `Object.assign(index, index)`, leaving
`index` undeclared: TS2304, and a ReferenceError at runtime.
Import such a child by its full path instead, and narrow the filter so it only
drops an "index" child that has no grandchildren, keeping the actions path
unchanged.
* just do map and implode once
* Update GenerateCommand.php
---------
Co-authored-by: Joe Tannenbaum <joe.tannenbaum@laravel.com>1 parent eeb2e52 commit 043c4af
3 files changed
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
406 | 412 | | |
407 | 413 | | |
408 | 414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
0 commit comments