Reference › Project
clarusjs 0.5.0
All releases · [email protected] on npm
Minor Changes
- Client routes:
routes: { '/app/*': 'client' }. A client route is answered with a shell (the island loader, a router under 1 KB gzip and a table of the client routes); the router loads the page's render module and its<path>/__data.json(params plusload(), written at build, served by the handler in dev and on a server), renders the page in the browser and attaches its islands. Navigations between client routes go through the Navigation API without reloads; browsers without it load pages normally, and a page that fails to render falls back to a normal load. The manifest andclarusjs explainshow client routes. Also fixes nested components in browser render modules: a?rendermodule now imports its child components as render modules too. #103 - Dynamic routes:
src/pages/users/[id].tsclrenders/users/<anything>, with each[param]passed to the page as a string input. Static routes win over dynamic ones. A static build lists a dynamic route's pages withentries()exported from[id].load.ts; a dynamic route without it, or an entry value that is empty,.,..or contains/, fails the build naming the file. #88 adapter: 'netlify':vite buildwrites a Netlify Function (.netlify/v1/functions/clarusjs-server.mjs, Frameworks API) that runs the samefetchhandler for server routes only, with their paths in URLPattern syntax and static files served first. No server routes, no function. An unknown adapter is a config error. #101- Per-route rendering modes:
clarusjs({ routes: { '/account/*': 'server' } }). Static routes (the default) are prerendered; server routes are left out of prerendering (a dynamic one needs noentries()) and render per request fromdist/server/index.mjs, withload()getting the visitor's request. The most specific pattern wins; an unknown mode or a malformed pattern is a config error.vite previewserves server routes through the built handler, and the route manifest andclarusjs explainshow each route's mode. #91 - Typed loaders: a page's
.load.tscan exportload({ params, request }). It runs on the server (at build time for prerendered pages, never in the browser), and what it returns is merged into the page's inputs.clarusjs checkchecks the returned value against the page's@inputtypes. A loader that throws or returns a non-object answers 500 with no internal details and logs the error (at build, the build fails naming the loader). The route manifest andclarusjs explainshow which pages ran a loader. #89 render(name, props)fromclarusjs/views: render any view undersrc/to HTML from server code (a loader, a script importing the built server), by its path without the extension (render('components/pill', { text })). The server entry registers every view, anddist/server/index.mjsexportsrendertoo.clarusjs checkwrites.clarusjs/views.d.ts, a registry of each view's inputs, so an unknown name or a wrong prop is a type error; add it to your tsconfig'sincludefor editor types. #104
Patch Changes
- README: the logo's alt text is just "clarusjs logo". #88