Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/frontends-option.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@solidjs/vite-plugin': minor
'@solidjs/vite-plugin': patch
---

Add a `frontends` option: other languages that lower to Solid can claim a file extension and compile its modules themselves (`frontends: { ".x": x() }`). A front end's `compile(source, { id, moduleId, ssr, root, solid, addWatchFile })` returns `{ code, map, css }`, given the compiler options this plugin would use for a JSX module in that environment; the result then takes the lowered `.tsrx` route (lazy and refresh passes, server functions keyed by the module's real path, `css` as a CSS module, dep scanning). Server functions in a front end's modules need `@solidjs/compiler` with secondary passes that accept any extension. `.rx` (ReactiveScript) is built in: with `@reactivescript/compiler` installed in the project, `.rx` modules compile with no option.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,30 @@ configureServerFunctionsServer({

Set `csrf: false` only when another trusted layer protects the endpoint.

Custom serialization (extra seroval plugins for class instances such as a
`Money` or an `ObjectId`) is configured the same way, once per side. Set the
server codec in the `configure` module and the client codec in
[`start.clientSetup`](#optionsstart), both from one shared options module:

```ts
// src/serialization.ts
import type { JSONCodecOptions } from '@solidjs/web/serialization';
export default { plugins: [MoneyPlugin] } satisfies JSONCodecOptions;

// src/server-config.ts (serverFunctions.configure)
import { configureServerFunctionsServer } from '@solidjs/web/server-functions/server';
import codec from './serialization';
configureServerFunctionsServer({ codec });

// src/client-setup.ts (start.clientSetup)
import { configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
import codec from './serialization';
configureServerFunctionsClient({ codec });
```

Both sides must use the same plugins. This covers server-function arguments
and results; the SSR hydration payload takes its own `plugins` option.

Meta-frameworks that need to control plugin ordering and dispatch requests
through their own server should use the standalone `serverFunctions()`
export instead, which never installs the dev middleware. See
Expand Down
Loading