$ the-wire · showcase
Wayfinder fixes duplicate route keys and barrel self-imports
By RepoJournal · Filed · About Laravel
Three pull requests across Laravel tooling tackle real code-generation bugs: Wayfinder now keys routes that share a URI by verb, and stops barrels importing themselves, while Surveyor hardens unary minus against non-numeric types.
Wayfinder generated broken action files when two routes pointed at the same invokable controller on the same URI, differing only by verb. Both routes landed in the same `__invoke` group, and every dictionary entry was keyed by URI alone, so the key was written twice and the const (named from a hash of the URI) was declared twice. The fix keys such routes by verb, so the generated code compiles. [1]
A second Wayfinder fix addresses barrels that imported themselves 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". With `photos.index` and `photos.index.window`, `photos/index.ts` emitted `import index<hash> from './index'`, producing TS7022 and TS2303 under tsc. Bundlers silently accepted it because `Object.assign(index, undefined)` is a no-op, so `photos.index.window` was dropped with no warning. [2]
Surveyor, the framework proposal tool, now guards unary minus against non-numeric types. Negating a union resolved every member without checking it was a number, so a union carrying an array or a string threw a TypeError. In production Debug caught it and the type quietly became mixed, which is why nothing ever surfaced. Both scalar and union paths now share a `negate()` helper that only negates IntType and FloatType and hands anything else back untouched. [3]
On the agent-skills front, the Laravel Cloud deployment skill was synced with laravel/cloud-cli PR #220, keeping agent behavior aligned with the cloud CLI's current contract. [4]
Action items
- → Update wayfinder to a build including route-keying and barrel self-import fixes if you use invokable controllers sharing a URI or route names that double as index prefixes laravel/wayfinder [plan]
- → Review surveyor output for unary minus on unions; the fix changes behavior only for non-numeric members, which previously threw or degraded to mixed laravel/surveyor [monitor]
References
- [1] Key routes that share a URI by verb ↗ laravel/wayfinder
- [2] Fix barrel self-import when a route name is both a leaf and a prefix … (#317) ↗ laravel/wayfinder
- [3] Guard unary minus against non-numeric types ↗ laravel/surveyor
- [4] Sync Laravel Cloud deployment skill with cloud-cli ↗ laravel/agent-skills