fix(plugin): install window.route stub for non-Laravel hosts#36
Open
fix(plugin): install window.route stub for non-Laravel hosts#36
Conversation
77 components in this package call Ziggy's route(name, params) helper, which is Laravel-specific. Non-Laravel hosts (Rails, Django, NestJS, Phoenix, etc.) don't ship Ziggy, so the calls fail with a bare ReferenceError deep inside component renders, giving the host developer zero hint about the underlying cause. Install a safety stub on window.route in EscalatedPlugin.install() that throws a descriptive error naming the missing dependency. Laravel hosts with Ziggy already loaded are left untouched; we only install the stub when window.route is undefined. This is not a functional Ziggy shim — full route() compat across 77 call sites is a separate, larger effort — but it makes the missing-dependency failure mode actionable.
Open
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
77 components in this package call Ziggy's
route(name, params)helper, which is Laravel-specific. Non-Laravel hosts (Rails, Django, NestJS, Phoenix, Go, .NET, Symfony, Adonis, Spring, WordPress) don't ship Ziggy, so the calls fail with a bareReferenceError: route is not defineddeep inside a component render. The host developer has no hint why.This PR installs a safety stub on
window.routeinsideEscalatedPlugin.install():window.routeis already defined (Laravel host with Ziggy loaded), leave it aloneWhat this is not: a functional Ziggy shim. Generating URLs for 77 call sites against each host framework's named-route table is a separate, much larger effort. This PR only improves the failure mode: instead of an unhelpful
ReferenceErrormid-render, the host gets a clear message naming the actual missing dependency.Why now
Flagged in the public-ticket-system rollout status doc as the final deferred follow-up. Minimum viable error-surface improvement that ships today without taking on the full Ziggy-compat scope.
Test plan
tests/plugin.test.js:installs a window.route stub on non-Laravel hosts— when nowindow.routeexists before plugin install, one is installed afterthe stub throws a descriptive error when called— contains the called route name and mentions Ziggydoes not overwrite an existing window.route from a Laravel host— if the host already installed Ziggy, the plugin doesn't touch it