-
-
Notifications
You must be signed in to change notification settings - Fork 167
test(rsc): add navigation
example
#567
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
@hi-ogawa I can't get npm run build/preview to work, although it was working on vite-plugins and hydration worked in that case. ![]() |
I'll continue work in vite-plugins PR for now because build/preview works there |
navigation
example
Thanks for the PR! The build error was because there was a copy of
The dev error is due to Vite's deps optimization. I added It looks like navigation has some issues (both dev and build) and also there's typescript error, which I'm not sure about. Please continue integration and feel free to ask me if anything unclear about Vite RSC. Thanks! |
@hi-ogawa Thank you, that's amazing 🙏 |
The built-in vite hydrate does too much - handles navigation, for example, which is no good because router needs to handle it
Also renamed to Shell to match other navigation rsc examples
Had to change method from post to put because vite interprets post as an action
Want all the app code to look as similar as possible across all navigation rsc examples
Updating People works but updating stateNavigator doesn't quite work. The update lags behind, so update 1 is only processed after update 2 - think it's because the rsc stream update happens before the updated state navigator loads in. With Person it's a server component so doesn't need loading - the rsc update contains the update
Matches other navigation rsc examples
The GET is the first request so should be the if not else
Not sure what it's for
Thanks @hi-ogawa for your help. I've finished the navigation example and it works great. It's server-rendered and then all subsequent clicks are fetched using rsc. The code is spit correctly, for example, the
|
Copied over from vitejs/vite-plugin-react#567
Thanks for the follow-up!
Yes, this is expected. At the moment, this won't be handled by It's interesting to know that this was the intentional decision by Parcel as I was wondering when I see their behavior in the past. Thanks for the reference!
Right, it wasn't explicitly mentioned here, but
I'm not familiar with this issue. Can you explain how to reproduce this? |
Yes, that would be great 🙏 |
…te-plugin-react into navigation-vite
Using starter template from vite (see vitejs/vite-plugin-react#567 (comment))
Copying from starter sample (see vitejs/vite-plugin-react#567 (comment))
Thanks for the help @hi-ogawa. I've followed the starter example and written the Navigation router integration through @vitejs/plugin-rsc/{rsc,ssr,browser} API. The only issue I have left is the hmr update. I'll leave this PR open to track it if that's ok with you? Or would you rather I raise a separate issue for it? |
What's the expectation of |
Hi @hi-ogawa there was a bug with the Navigation router that prevented Vite HMR from working. I’ve fixed that but now I’ve found something odd with Vite HMR that hopefully you can help with. If you run the latest navigation example and edit the route in the {
key: 'people',
route: 'test1{page?}',
defaults: { page: 1, sort: 'asc', size: 10 },
}, The problem happens when you edit the route a second time to 'test2{page?}', for example. The Why does the 2nd Vite HMR update behave so differently to the 1st? |
Hey, I really appreciate you continue testing out the HMR capability! 🙏 Unfortunately, I still don't yet have the bandwidth to dig into
|
Editing the key in the lookup file from 'a' to 'b' throws an error because the rsc response from the server has 'b' but the client lookup still has 'a' in it. The hmr rsc response returns before the lookup has been updated on the client
…te-plugin-react into navigation-vite
Hey @hi-ogawa thanks for your response. I've created a separate example called 'hmr' without any navigation dependencies to make the problem clearer. The export const key = 'b' The reason for the error is that the server response uses the latest 'lookup.ts' but the client uses the old 'lookup.ts'. So the rsc response has the key 'b' but the client still has the key 'a'. |
Great! thanks for the isolated repro 👍 There is indeed something I haven't fully thought through about shared module, which exists both inside server module graph and client module graph
I would've expected this case being not working at all, so I'm surprised there's some difference between 1st update and 2nd update. This sounds like a concrete bug. Can you create an issue with your repro or just link to this PR? |
Copied over from vite-plugins.
Hi @hi-ogawa , thank you for working on a vite rsc implementation.
I'm the author of the Navigation router, an rsc framework for react. I'd already written example rsc apps to test out parcel and webpack. So I've started to do the same for your vite implementation. This PR isn't meant to be merged but is a good way to communicate any issues I find.
I cloned your basic example and copied in the files from my working parcel example. When I run
npm run dev
the ssr works but the hydration fails. It fails because the react context isn't populated as expected. It seems like vite has 2 versions of the file - 1 inside the bundled navigation-react.js and one standalone. You can see in the screenshot below it says "from SceneRSCView" instead of "from navigation-react.js". The react context is created from navigation-react.js so it can't be found if it's not accessed the same way. This is just my guess as to what's going wrong.For some background, The
navigation-react
package has different exports for server and client and has internal client boundaries. TheSceneRSCView
, where the error is happening, is one of these.Thanks again for all your work.