-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Routing overridability #40
Conversation
I see the following options for how we expose configuration of the matcher:
|
Looking forward to have a look at all of this!
Can I see this somewhere? I'd love to see the end result of your work. |
Here let me do this - I'll get this setup working in the vue-router example and make those changes part of this PR. |
Perfect. I will finish my context props work and then have a look at your PR. Very curious to see the deep integration. |
Couple of notes:
|
I suggest the following next steps:
The Vite plugin is for building which we don't need to change. Instead, AFAICT, the following should work. // _default.client.js
import { useVueRouter } from '@vite-plugin-ssr/vue-router/client';
// ... // server/index.js
import { createPageRender } from 'vite-plugin-ssr'
import { useVueRouter } from '@vite-plugin-ssr/vue-router';
const renderPage = createPageRender({ viteDevServer, isProduction, root, customRouting: useVueRrouter });
// ...
export { changeRouteStringResolver }
let customResolver
function changeRouteStringResolver(customResolver_) {
customResolver = customResolver_
}
function resolveRouteString(...args) {
if( customResolver ) {
return customResolver(...args)
}
// Default behavior
// ...
} Looking forward to have Vue Router deeply intergrated! |
The thing is, there are parts of this refactor that are required for the integration to work. If you'd like me to recombine some of these files into single-use functions within their respective files, I can do that. I can also help navigate any merge conflicts and fix tests. The real problem that the refactor seeks to address in order to make the integration possible, is that you have baked the matching logic into the route function. For a Vue Integration to work, we need to rely on their matching logic. This is because I can't parse a Vue route and get back For these reasons, your suggestion of exposing |
The code structure you're proposing should work, with the caveat that as I said in my previous comment, |
Mainly the moving of functions into their own file. IIRC reverting this should do it. If there is anything else I can let you know. Just ping me when there are changes on the PRs. Let me know if you need anything else. |
👍. I'll add you to the repo. |
Ok! I'll only split out the functions that seem like they're begging for it and let you know when that's complete. |
Perfect. I merged my changes to master; as expected there are merge conflicts. See the CHANGELOG.md to see why the changes have been made. As usual, let me know if you have any question. |
…ue-router example
@brillout I've recombined some of the routing functions (I looked for anything that was single use and added it back to the file where it was being used). I also merged from master and resolved the merge conflicts, did some various clean up / refactor... and also created a package for vue router as you described. Please have a look. I suppose the last thing to figure out is this stuff about the route functions, whether we're ending support of some part of that feature to make client routing integration easier. |
Won't be at my computer until Monday. I haven't looked at your previous comments yet, but if you've got ideas about changes you'd like to make, feel free! |
👍 I'll wait :-) |
Sorry, pretty slammed with other stuff at the moment. I haven't forgotten about this and will try to get to it ASAP. |
No rush, take all the time you need :-)
…On Tue, May 11, 2021 at 10:48 PM Gryphon Myers ***@***.***> wrote:
Sorry, pretty slammed with other stuff at the moment. I haven't forgotten
about this and will try to get to it ASAP.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#40 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVQRVEG4YXT533WT3VQPLTNGJYRANCNFSM422XVK2A>
.
|
@gryphonmyers Any updates on this? Let me know if anything changed on your side, e.g. if you stopped being interested in using Vue Router with |
@brillout nope I just have to deliver a big project with a deadline so have been focusing all my dev time on that. Sorry for the delay, will get back to it when I can. |
No worries. Do you have an ETA for that big project? I'm just asking to plan my work on vite-plugin-ssr. |
About a month. Since we were so close on this I might try to squeeze in some time before then to wrap it up, maybe on a weekend. |
No don't worry, I'll do the wrap up. Thank you for your wonderful work. I'll let you know if I have questions. |
59318f6
to
232af03
Compare
I didn't manage to run the vue-router example, let's wait until you have more time to finish up the PR. |
Let me know if you need help merging/rebasing on master. There will be a couple of merge conflicts. |
Ok sorry for the delay - never thought the PR would be open this long |
No worries :-) |
OK I just merged from master and I THINK I resolved all the merge conflicts. Still need to run some code and get the tests working. |
@brillout I'm having some issues with the tests - they seem to cause my vue-router package to use an out-of-date (not symlinked) version of vite-plugin-ssr, even though I have it in the package.json as a local path. Any idea what might be causing this? I can confirm an npm install into that directory produces a correct symlink, but running the test command, it somehow gets the bad, non-symlinked copy. |
Yes that's because You can add it to |
Btw. have you thought abour our original conversation? I was arguing that using Vue Router with While I agree that Thoughts? |
I mean I've personally seen several people asking how to use it with vue-router and the current answer is you kind of can, but it's complicated to set up and not at all ideal. Nuxt has tight coupling to vue-router (TOO tight if you ask me), but many refugees from that project will expect the integrations it provides. I've already made my points about the advantages of client routing, and your homebrew routing is fine for simple use cases but cannot replace vue-router as it does not integrate with the rendering framework. |
I think the direction we have going here is solid: an opt-in package to integrate a popular rendering framework's companion router painlessly with the plugin's structural conventions. Way more versatile than Nuxt and will be just as powerful if we can ever get this pr merged! I do have a few ideas about further improvements but let's save that for later. |
@@ -5,6 +5,7 @@ import { assert, assertUsage } from './utils/assert' | |||
import { normalize as pathNormalize } from 'path' | |||
import { ViteDevServer } from 'vite' | |||
import { assertBaseUrl } from './baseUrlHandling' | |||
import { RoutingHandler, setCustomRouter } from './route.shared'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import RoutingHandler
is not used; we can remove it.
The |
This PR seeks to do the following
At present, note that vue-router has been added to the dependencies and the
matchRoutes
implementation in route.shared.ts has been switched from the pathToRegexp matcher to a Vue Router matcher. This was to verify as a POC, but probably ideally the matcher should be customizable via a plugin interface. At the very least, configuration allowing the user to choose the underlying matcher should be exposed.Also note that previously, functional routes were expected to return objects in a
{ matchValue: boolean|number, routeParams: Record<string, unknown> }
signature. I have expanded this to allow for returning a routing string instead, which will then be parsed and matched as any other path string. The reason for this is that functional routes are compiled on the server, and once the routes get to the client, we should have them in a format that is easily understood by the configured matcher. In the case of Vue Router, this is a Vue Router path string (similar to pathToRegexp, but slightly different) so it will not know what to do with{ matchValue: boolean|number, routeParams: Record<string, unknown> }
. For the same reason, I have added a warning when users try to use that signature with the Vue Router matcher.Please review and let me know of any concerns. I do have a basic proof of concept working end-to-end, and can share the specifics of the front-end integration if desired (I'm planning to eventually package them into an additional plugin or at the very least documentation).