Skip to content

fix(plugin): install window.route stub for non-Laravel hosts#36

Open
mpge wants to merge 3 commits intomainfrom
fix/route-helper-shim
Open

fix(plugin): install window.route stub for non-Laravel hosts#36
mpge wants to merge 3 commits intomainfrom
fix/route-helper-shim

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented Apr 24, 2026

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 bare ReferenceError: route is not defined deep inside a component render. The host developer has no hint why.

This PR installs a safety stub on window.route inside EscalatedPlugin.install():

  • If window.route is already defined (Laravel host with Ziggy loaded), leave it alone
  • Otherwise, install a function that throws a descriptive error identifying the missing dependency and pointing at Ziggy

What 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 ReferenceError mid-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

  • 3 new tests in tests/plugin.test.js:
    • installs a window.route stub on non-Laravel hosts — when no window.route exists before plugin install, one is installed after
    • the stub throws a descriptive error when called — contains the called route name and mentions Ziggy
    • does not overwrite an existing window.route from a Laravel host — if the host already installed Ziggy, the plugin doesn't touch it
  • All 522 tests pass (was 519 + 3 new = 522)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant