@jk2908/solas 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +39 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -566,7 +566,11 @@ export default defineConfig({
|
|
|
566
566
|
})
|
|
567
567
|
```
|
|
568
568
|
|
|
569
|
-
##
|
|
569
|
+
## Adapters
|
|
570
|
+
|
|
571
|
+
Adapters run at build time. Pass one to `solas({ adapter })`; it configures the build output for a platform.
|
|
572
|
+
|
|
573
|
+
### Cloudflare
|
|
570
574
|
|
|
571
575
|
Solas ships a Cloudflare adapter that runs the RSC server as a Worker and serves prerender artifacts and client assets through the Cloudflare assets binding.
|
|
572
576
|
|
|
@@ -608,7 +612,7 @@ export default defineConfig({
|
|
|
608
612
|
|
|
609
613
|
> `cloudflare.config.ts` is an open beta and must be loaded with Node 22.18+ (Bun is not supported), so the Cloudflare build and deploy commands run under Node. See the [`cf` documentation](https://developers.cloudflare.com/cf/) for the format and the `cf dev` / `cf build` / `cf deploy` commands.
|
|
610
614
|
|
|
611
|
-
|
|
615
|
+
#### Bindings
|
|
612
616
|
|
|
613
617
|
Bindings are declared in `cloudflare.config.ts` and read with the standard Cloudflare global. The adapter does not manage them:
|
|
614
618
|
|
|
@@ -654,17 +658,38 @@ The adapter:
|
|
|
654
658
|
|
|
655
659
|
`htmlHandling: none` stops the asset layer serving a prerendered document at its route path. That matters because the asset layer ignores `Accept`, so an RSC navigation (`Accept: text/x-component`) to a fully-prerendered route would otherwise receive HTML and fail to parse. Routing documents through the Worker lets Solas serve the prerender for `text/html` and render RSC otherwise, while non-HTML assets (JS, CSS, fonts, images) are still served straight from the asset layer.
|
|
656
660
|
|
|
657
|
-
|
|
661
|
+
`cloudflare()` forwards its `cloudflare` option to `@cloudflare/vite-plugin`.
|
|
658
662
|
|
|
659
|
-
|
|
663
|
+
### Static
|
|
664
|
+
|
|
665
|
+
The static adapter sets `prerender: 'full'` so every route is rendered to HTML at build time, then assembles a directory any static host can serve. There is no server.
|
|
660
666
|
|
|
661
667
|
```ts
|
|
662
|
-
|
|
668
|
+
// vite.config.ts
|
|
669
|
+
import { defineConfig } from 'vite'
|
|
663
670
|
|
|
664
|
-
|
|
671
|
+
import solas from '@jk2908/solas'
|
|
672
|
+
import staticAdapter from '@jk2908/solas/adapters/static'
|
|
673
|
+
import react from '@vitejs/plugin-react'
|
|
674
|
+
|
|
675
|
+
export default defineConfig({
|
|
676
|
+
plugins: [solas({ adapter: staticAdapter() }), react()],
|
|
677
|
+
})
|
|
665
678
|
```
|
|
666
679
|
|
|
667
|
-
|
|
680
|
+
`vite build` writes the site to `build/` (override with `outDir`): the client assets, each route as `<route>.html` (or `<route>/index.html` under `trailingSlash: 'always'`), its RSC payload as `<route>.rsc.txt`, plus `sitemap.xml` and `robots.txt`. Serve that directory with anything — `npx serve build`, GitHub Pages, Netlify, an S3 bucket, nginx.
|
|
681
|
+
|
|
682
|
+
Client-side navigation works with no server: the browser router fetches each route's `<route>.rsc.txt` payload instead of asking a server for `text/x-component`.
|
|
683
|
+
|
|
684
|
+
Because it forces full prerendering, routes that need a server are not a fit: per-route PPR or SSR opt-ins and dynamic routes without `params()`.
|
|
685
|
+
|
|
686
|
+
Server actions and runtime endpoints also need a server, so the build warns when the graph contains any (a `'use server'` module or a `+endpoint` file).
|
|
687
|
+
|
|
688
|
+
## Runtime helpers
|
|
689
|
+
|
|
690
|
+
Runtime helpers run at request time. They live under `@jk2908/solas/runtime/*` and are never passed to `solas({ adapter })`.
|
|
691
|
+
|
|
692
|
+
### Node
|
|
668
693
|
|
|
669
694
|
`vite dev` and `vite preview` already run the built handler in Node (via `@vitejs/plugin-rsc`'s default server handler), so nothing extra is needed locally. For a production Node server, use `@jk2908/solas/runtime/node`:
|
|
670
695
|
|
|
@@ -690,8 +715,6 @@ Set `NODE_ENV=production` before starting. React reads it when the built handler
|
|
|
690
715
|
|
|
691
716
|
Set `precompress: true` in the Solas config to emit brotli variants of client and prerendered assets at build time. `serve()` negotiates them when the client sends `accept-encoding: br` and falls back to the original file otherwise. Dynamic HTML and RSC responses are streamed per request and are not precompressed, so compress those at a proxy or CDN if you need it.
|
|
692
717
|
|
|
693
|
-
`serve` is a runtime helper, not a build adapter: it starts an HTTP server and returns it, so it belongs in `server.ts`. Do not pass it to `solas({ adapter })`; that option expects an `Adapter` with `name` and `plugins`, such as `cloudflare()` or the static adapter.
|
|
694
|
-
|
|
695
718
|
For TLS, mount the handler on your own `https` server:
|
|
696
719
|
|
|
697
720
|
```ts
|
|
@@ -741,32 +764,19 @@ Deno.serve(request => handler.fetch(request))
|
|
|
741
764
|
|
|
742
765
|
The handler reads `dist` through `node:fs`, which Bun and Deno (2.x, via Node compat) provide. Run from the project root. Bun can also run `@jk2908/solas/runtime/node` as-is, since it implements `node:http`.
|
|
743
766
|
|
|
744
|
-
|
|
767
|
+
### Cloudflare runtime
|
|
745
768
|
|
|
746
|
-
|
|
769
|
+
Because workers have no filesystem, the Worker reads its own output through the `ASSETS` binding. Reads use logical namespaces rather than filesystem paths: `client` maps onto asset-root URLs, and `static` (prerenders) and `artifact` (manifest, ppr) map onto the artifact prefix. During the build-time prerender pass the Worker is invoked without bindings, so the Node asset store is used and reads/writes artifacts on disk.
|
|
747
770
|
|
|
748
|
-
|
|
749
|
-
// vite.config.ts
|
|
750
|
-
import { defineConfig } from 'vite'
|
|
771
|
+
To build a Worker manually, `createWorker` composes the entry behaviour, and `createCloudflareAssets` builds the store directly:
|
|
751
772
|
|
|
752
|
-
|
|
753
|
-
import
|
|
754
|
-
import react from '@vitejs/plugin-react'
|
|
773
|
+
```ts
|
|
774
|
+
import { createCloudflareAssets } from '@jk2908/solas/runtime/cloudflare'
|
|
755
775
|
|
|
756
|
-
|
|
757
|
-
plugins: [solas({ adapter: staticAdapter() }), react()],
|
|
758
|
-
})
|
|
776
|
+
const assets = createCloudflareAssets(env)
|
|
759
777
|
```
|
|
760
778
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
Client-side navigation works with no server: the browser router fetches each route's `<route>.rsc.txt` payload instead of asking a server for `text/x-component`.
|
|
764
|
-
|
|
765
|
-
Because it forces full prerendering, routes that need a server are not a fit: per-route PPR or SSR opt-ins and dynamic routes without `params()`.
|
|
766
|
-
|
|
767
|
-
Server actions and runtime endpoints also need a server, so the build warns when the graph contains any (a `'use server'` module or a `+endpoint` file).
|
|
768
|
-
|
|
769
|
-
## Runtime
|
|
779
|
+
### Asset store
|
|
770
780
|
|
|
771
781
|
At request time Solas reads its output through an `Assets` interface (`exists`/`readText`/`readBuffer`/`mimeType`) injected into `createHandler`, defaulting to the Node standard library (which Bun runs natively). References are logical (`{ namespace, path }`), where the namespaces are `client` (Vite client output), `static` (full prerenders), and `artifact` (runtime manifest and ppr files). Platforms without a filesystem provide their own store; `@jk2908/solas/runtime/cloudflare` builds one around the `ASSETS` binding via `createWorker`. Build-time reads and writes use `node:fs` directly and are not abstracted.
|
|
772
782
|
|
package/package.json
CHANGED