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
5 changes: 5 additions & 0 deletions .changeset/eleven-actors-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

fix(types): add missing properties to `SolidStartOptions` and expose them via Vite plugin configuration
103 changes: 91 additions & 12 deletions packages/start/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,109 @@ import lazy from "./lazy.ts";
import { manifest } from "./manifest.ts";
import { parseIdQuery } from "./utils.ts";

/**
* Configuration options for SolidStart. (previously in `app.config.ts`)
*
* @see https://docs.solidjs.com/solid-start/v2/migrating-from-v1#move-framework-configuration-into-viteconfigts
*/
export interface SolidStartOptions {
/**
* Path to the root of the application (where `app.tsx` / `app.jsx` lives).
*
* @default "./src"
*/
appRoot?: string;

/**
* Options forwarded to `vite-plugin-solid`.
*
* @see https://github.com/solidjs/vite-plugin-solid#api
*/
solid?: Partial<SolidOptions>;

/**
* Enable or disable server-side rendering.
*
* - `true` — SSR (default)
* - `false` — client-side rendering only (SPA mode)
*
* @default true
*/
ssr?: boolean;

/**
* Show the SolidStart development overlay (error overlay, etc.) in development.
*
* @default true
*/
devOverlay?: boolean;

/**
* Experimental features.
*/
experimental?: {
/**
* Enable islands architecture mode.
*
* Currently fixed to `false` (not yet fully supported).
*
* @default false
*/
islands?: false;
};

/**
* Directory containing file-system routes, relative to {@link appRoot}.
*
* @default "./routes"
*/
routeDir?: string;

/**
* File extensions that should be treated as routes.
*
* @default ["js", "jsx", "ts", "tsx"]
*/
extensions?: string[];

/**
* Path to an optional middleware module.
*
* The module should export a middleware created with `createMiddleware`
* from `@solidjs/start/middleware`.
*
* @example "src/middleware/index.ts"
*/
middleware?: string;

/**
* Serialization settings for server-function / action payloads
* that cross the server-client boundary.
*/
serialization?: {
/**
* The serialization mode to use for server functions/actions.
* The "js" mode uses a custom binary format that is more efficient than JSON, but requires a custom deserializer (with `eval()`) on the client.
* A strong CSP should block `eval()` executions, which would prevent the "js" mode from working.
* The "json" mode uses JSON for serialization, which is less efficient but can be deserialized with `JSON.parse` on the client.
*
* - `"js"` — Uses a custom binary format (Seroval) that is more efficient
* than JSON, but requires a custom deserializer (with `eval()`) on the client.
* A strong CSP that blocks `eval()` will prevent this mode from working.
* - `"json"` — Uses JSON for serialization. Less efficient / larger payloads,
* but can be deserialized with `JSON.parse` on the client and is CSP-friendly.
*
* @default "json"
*/
mode?: "js" | "json";
};

/**
* Configures plugin behavior per build environment
*/
env?: EnvPluginOptions;

/**
* Options controlling which files are processed as server functions
* (inclusion / exclusion filters for the `"use server"` transform).
*/
serverFunctions?: Pick<ServerFunctionsOptions, "filter">;
}

Expand All @@ -50,7 +135,7 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
},
solid: {},
extensions: [],
});
} satisfies SolidStartOptions);
const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
const routeDir = join(start.appRoot, start.routeDir);
const root = process.cwd();
Expand Down Expand Up @@ -224,15 +309,9 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
enforce: "pre",
resolveId(id, importer, { ssr }) {
if (id === "server-only") {
if (!ssr)
this.error(
`Attempt to import 'server-only' in a client module: ${importer}`,
);
if (!ssr) this.error(`Attempt to import 'server-only' in a client module: ${importer}`);
} else if (id === "client-only") {
if (ssr)
this.error(
`Attempt to import 'client-only' in a server module: ${importer}`,
);
if (ssr) this.error(`Attempt to import 'client-only' in a server module: ${importer}`);
} else {
return null;
}
Expand Down
Loading