-
Notifications
You must be signed in to change notification settings - Fork 132
Fix various TypeScript issues, simplify ziggy-js integration and shared props usage #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…itly type the props
This type reference does not exist.
Continuation of #87 |
Maybe we should go ahead and use wayfinder instead of ziggy? |
I plan to switch to Wayfinder once it’s stable, but given Ziggy’s long history of being preconfigured in the starter kits, I think it should remain available—perhaps as an install-time option? |
Thanks for this, Tim! While we are on the subject of Ziggy: is there a specific reason why all the Ziggy routes are a part of the Inertia shared data as well? The routes are already part of the page via the global Vue configuration, no? |
As I understand it, this is necessary because the SSR script doesn’t have access to the Blade file’s contents. When the server renderer tries to read the routes that the Blade file would normally declare, it fails. The client-side script works fine, however, because by the time it executes, the routes have already been declared and are available in the browser. That’s why we need to pass the routes via shared properties. Technically, this should only be necessary in the initial, server-rendered response. If an X-Inertia header is present on subsequent requests, we could skip that step, if I’m not mistaken. This discrepancy has been a real pain point for me in the past—SSR errors (for example, accessing document or window) are easy to overlook during development if the client-side script still runs without issue. Edit: While digging a little bit deeper I stumbled across those posts, basically all outlining the same problem: https://github.com/tighten/ziggy/discussions?discussions_q=is%3Aopen+ssr This post basically ends up with what we have now I believe |
Really appreciate the thorough explanation, Tim! I won't be using SSR any time soon, so I just removed the sharing of the Ziggy routes in Inertia and replaced the one reference to it (resources\js\layouts\settings\Layout.vue) with a reference to the
becomes:
|
This pull request simplifies type usage, removes unused imports, and improves the SSR setup.
Ziggy-JS
While following the Ziggy-JS setup guide, I noticed that our ssr.ts file does a lot of unnecessary work. We can replace most of it with the ziggyVue plugin. We also don’t need the Ziggy alias pointing to the vendor directory, since Ziggy is already installed as a JS dependency. Finally, I added proper Vue-specific route definitions.
TypeScript Types
vue/tsx
entry from the types array. It wasn’t provided by any installed package and caused errors during vue-tsc type checks.