Skip to content
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

feat(react-server): preload client references #257

Closed
wants to merge 37 commits into from

Conversation

hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Apr 2, 2024

Demo screenshot

The bottom one shows hovering /test/deps is triggering client reference assets before fetching rsc.

image

todo 2

  • Is it possible to collect client boundary by resolveId importer? I feel we shouldn't technically need lazy import glob to get this feature
  • or we can entirely replace assets preloading with rsc prefetching, so that server only needs to figure out relevant client assets during runtime?

todo

  • make server glob routes lazy so it's easier to collect per-route information from vite manifest?
    • lazy loading should help react server startup too.
  • build time
    • disable client reference id hashing for easier debugging?
    • serve route to client reference mapping
    • client reference to js/css assets mapping
    • route tree
  • runtime
    • route tree matching util
    • ssr preload
      • render from react-server via preload api?
      • actually this is not necessary if we setup bundler config chunks?
    • pass manifest to client
    • client preload
  • also preload obviously known client dynamic deps (client-reference.js and react-server-dom-webpack/client.browser)
  • test
  • refactor

@hi-ogawa hi-ogawa changed the title feat(react-server): prefetch client deps per route feat(react-server): preload client assets per route Apr 3, 2024
@hi-ogawa hi-ogawa changed the title feat(react-server): preload client assets per route feat(react-server): preload client assets on hover Apr 3, 2024
@hi-ogawa hi-ogawa marked this pull request as ready for review April 3, 2024 06:34
@hi-ogawa hi-ogawa changed the title feat(react-server): preload client assets on hover feat(react-server): preload client references Apr 3, 2024
@hi-ogawa hi-ogawa mentioned this pull request Apr 3, 2024
69 tasks
@hi-ogawa
Copy link
Owner Author

hi-ogawa commented Apr 10, 2024

I'm hesitant to land this feature, so let's split a bit

@hi-ogawa
Copy link
Owner Author

hi-ogawa commented Jun 3, 2024

This will be superseded by

Put this in draft for now

@hi-ogawa hi-ogawa marked this pull request as draft June 3, 2024 05:25
@hi-ogawa hi-ogawa closed this Jun 4, 2024
@hi-ogawa hi-ogawa deleted the feat-prefetch-client-dep branch June 4, 2024 00:22
hi-ogawa added a commit that referenced this pull request Jun 4, 2024
Picking up some code from
- #257

Preparing for
- #337

The idea is to extract routing logic (fs route tree generation + route matching) out of react-server world, so it can be used anywhere as a pure utility. This also helps test-ability.
hi-ogawa added a commit that referenced this pull request Jun 4, 2024
…#331)

- related #257

Looking back #257, the manifest manipulation looks to complicated, so I'm trying a new approach here.

## todo

- build time
  - [x] use `transform.meta` and `PluginContext.getModuleInfo` to map from route to client reference (during server build)
  - [x] map client reference id to browser asset file (during browser build)
- runtime
  - [ ] this is probably unavoidable and just need to copy #257
        separate PR?
- [ ] test
hi-ogawa added a commit that referenced this pull request Jun 4, 2024
- supersedes #257

Probably I should rework/refactor route tree manipulation first. 

- [x] refactor tree utils (separated in #338)
- [x] preload from ssr
- [ ] preload from browser
- [ ] preload css
- [ ] preload during dev?
hi-ogawa added a commit that referenced this pull request Jun 4, 2024
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