Skip to content
Closed
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/cyan-jokes-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": minor
---

change server function compiler to dismantle
3 changes: 3 additions & 0 deletions apps/tests/src/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ export default createHandler(() => (
)}
/>
));


import 'solid-start/fns/preload';
3 changes: 1 addition & 2 deletions apps/tests/src/functions/use-is-server-const.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use server";

import { isServer } from "solid-js/web";

export const serverFnWithIsServer = async () => {
"use server";
return isServer;
};
3 changes: 2 additions & 1 deletion apps/tests/src/functions/use-is-server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use server";


import { isServer } from "solid-js/web";

export function serverFnWithIsServer() {
"use server";
return isServer;
}
3 changes: 1 addition & 2 deletions apps/tests/src/functions/use-node-builtin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use server";

import { join } from "node:path";

export function serverFnWithNodeBuiltin() {
"use server";
return join("can", "externalize");
}
3 changes: 2 additions & 1 deletion apps/tests/src/functions/use-npm-module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use server";


import _ from "lodash";

export function serverFnWithNpmModule() {
"use server";
return _.map([1, 2, 3], x => x * 2);
}
3 changes: 2 additions & 1 deletion apps/tests/src/functions/use-server-function-meta.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use server";


import { getServerFunctionMeta } from "@solidjs/start";

export function serverFnWithMeta() {
"use server";
return typeof getServerFunctionMeta()?.id;
}
2 changes: 1 addition & 1 deletion packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@babel/traverse": "^7.28.3",
"@babel/types": "^7.28.5",
"@solidjs/meta": "^0.29.4",
"@tanstack/server-functions-plugin": "1.134.5",
"dismantle": "^0.6.1",
"@types/babel__traverse": "^7.28.0",
"@types/micromatch": "^4.0.9",
"cookie-es": "^2.0.0",
Expand Down
39 changes: 3 additions & 36 deletions packages/start/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { TanStackServerFnPlugin } from "@tanstack/server-functions-plugin";

import { defu } from "defu";
import { globSync } from "node:fs";
import { extname, isAbsolute, join } from "node:path";
import { fileURLToPath } from "node:url";
import { normalizePath, type PluginOption } from "vite";
import solid, { type Options as SolidOptions } from "vite-plugin-solid";

Expand All @@ -14,6 +13,7 @@ import type { BaseFileSystemRouter } from "./fs-routes/router.ts";
import lazy from "./lazy.ts";
import { manifest } from "./manifest.ts";
import { parseIdQuery } from "./utils.ts";
import { serverFunctionsPlugin } from "./server-functions.ts";

export interface SolidStartOptions {
solid?: Partial<SolidOptions>;
Expand Down Expand Up @@ -163,42 +163,9 @@ export function solidStart(options?: SolidStartOptions): Array<PluginOption> {
},
}),
lazy(),
serverFunctionsPlugin({}),
// Must be placed after fsRoutes, as treeShake will remove the
// server fn exports added in by this plugin
TanStackServerFnPlugin({
// This is the ID that will be available to look up and import
// our server function manifest and resolve its module
manifestVirtualImportId: VIRTUAL_MODULES.serverFnManifest,
directive: "use server",
callers: [
{
envConsumer: "client",
envName: VITE_ENVIRONMENTS.client,
getRuntimeCode: () =>
`import { createServerReference } from "${normalizePath(
fileURLToPath(new URL("../server/server-runtime", import.meta.url))
)}"`,
replacer: opts => `createServerReference('${opts.functionId}')`,
},
{
envConsumer: "server",
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
],
provider: {
envName: VITE_ENVIRONMENTS.server,
getRuntimeCode: () =>
`import { createServerReference } from '${normalizePath(
fileURLToPath(new URL("../server/server-fns-runtime", import.meta.url))
)}'`,
replacer: opts => `createServerReference(${opts.fn}, '${opts.functionId}')`,
},
}),
{
name: "solid-start:virtual-modules",
async resolveId(id) {
Expand Down
Loading
Loading