zth / rescript-relay-router

MIT License
16 stars 3 forks source link

ReScriptify Server and implement asset loading #51

Closed Kingdutch closed 2 years ago

Kingdutch commented 2 years ago

The individual commits contain most of the explanation of what is happening.

The goal was to turn server.mjs into a Server.res file so that we have ReScript across the board. In so doing I also wanted to limit the needed API surface for EntryServer.res, making the thing that handles "Setting up a webserver" and "Turning a request into a React response" two separate things. Doing so should make it easier to support different webservers such as Fastify or different environments such as Cloudflare workers. It also more clearly encapsulates what is scaffolding and what is actually React related. This should make moving things around in the router easier too.

While doing so asset preloading was something that was most spread out and as such got quite a bit of attention. As a result we now have asset preloading working (although not yet for the assets of the initial route match, only assets emitted by React) in both development and production for both SSR and CSR.