Skip to content

Commit a97093f

Browse files
authored
fix: move getServerFunctionMeta export to @solidjs/start (#1773)
1 parent b47ba53 commit a97093f

File tree

9 files changed

+70
-5
lines changed

9 files changed

+70
-5
lines changed

.changeset/metal-ladybugs-check.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Move `getServerFunctionMeta` from `@solidjs/start/server` to `@solidjs/start` to fix circular import issues.
6+
7+
The old export at `@solidjs/start/server` still exists, but is **deprecated** and will be removed in a future release.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ node_modules
2626

2727
.tmp
2828
test/playwright-report
29+
tests/server-function/cypress/screenshots
2930

3031
# Temp
3132
gitignore

packages/start/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @refresh skip
2+
export { default as clientOnly } from "./shared/clientOnly";
23
export { GET } from "./shared/GET";
34
export { HttpHeader } from "./shared/HttpHeader";
45
export { HttpStatusCode } from "./shared/HttpStatusCode";
5-
export { default as clientOnly } from "./shared/clientOnly";
6-
6+
export { getServerFunctionMeta } from "./shared/serverFunction";

packages/start/src/server/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// @refresh skip
2-
export { StartServer } from "./StartServer";
32
export { createHandler } from "./handler";
4-
export { getServerFunctionMeta } from "./serverFunction";
3+
export { StartServer } from "./StartServer";
54
export type {
65
APIEvent,
76
APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta
87
} from "./types";
8+
import { getServerFunctionMeta as getServerFunctionMeta_ } from "../shared/serverFunction";
99

10+
/** @deprecated */
11+
export const getServerFunctionMeta = getServerFunctionMeta_;

packages/start/src/server/serverFunction.tsx renamed to packages/start/src/shared/serverFunction.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getRequestEvent } from "solid-js/web";
2-
import type { ServerFunctionMeta } from "./types";
2+
import type { ServerFunctionMeta } from "../server/types";
33

44
/**
55
*

tests/server-function/cypress/e2e/server-function.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ describe("server-function", () => {
77
cy.visit("/is-server-nested");
88
cy.get("#server-fn-test").contains('{"serverFnWithIsServer":true}');
99
})
10+
it("should have an id of type string in the server function meta - nested", () => {
11+
cy.visit("/server-function-meta-nested");
12+
cy.get("#server-fn-test").contains('{"serverFnWithMeta":"string"}');
13+
})
1014
it("should externalize node builtin in server function - nested", () => {
1115
cy.visit("/node-builtin-nested");
1216
cy.get("#server-fn-test").contains('{"serverFnWithNodeBuiltin":"can/externalize"}');
@@ -20,6 +24,10 @@ describe("server-function", () => {
2024
cy.visit("/is-server-toplevel");
2125
cy.get("#server-fn-test").contains('{"serverFnWithIsServer":true}');
2226
})
27+
it("should have an id of type string in the server function meta - toplevel", () => {
28+
cy.visit("/server-function-meta");
29+
cy.get("#server-fn-test").contains('{"serverFnWithMeta":"string"}');
30+
})
2331
it("should externalize node builtin in server function - toplevel", () => {
2432
cy.visit("/node-builtin-toplevel");
2533
cy.get("#server-fn-test").contains('{"serverFnWithNodeBuiltin":"can/externalize"}');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use server";
2+
3+
import { getServerFunctionMeta } from "@solidjs/start";
4+
5+
export function serverFnWithMeta() {
6+
return typeof getServerFunctionMeta()?.id;
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { getServerFunctionMeta } from "@solidjs/start";
2+
import { createEffect, createSignal } from "solid-js";
3+
4+
function serverFnWithMeta() {
5+
"use server";
6+
7+
return typeof getServerFunctionMeta()?.id;
8+
}
9+
10+
export default function App() {
11+
const [output, setOutput] = createSignal<{ serverFnWithMeta?: string }>({});
12+
13+
createEffect(async () => {
14+
const result = await serverFnWithMeta();
15+
setOutput(prev => ({ ...prev, serverFnWithMeta: result }));
16+
});
17+
18+
return (
19+
<main>
20+
<span id="server-fn-test">{JSON.stringify(output())}</span>
21+
</main>
22+
);
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createEffect, createSignal } from "solid-js";
2+
import { serverFnWithMeta } from "~/functions/use-server-function-meta";
3+
4+
export default function App() {
5+
const [output, setOutput] = createSignal<{ serverFnWithMeta?: string }>({});
6+
7+
createEffect(async () => {
8+
const result = await serverFnWithMeta();
9+
setOutput(prev => ({ ...prev, serverFnWithMeta: result }));
10+
});
11+
12+
return (
13+
<main>
14+
<span id="server-fn-test">{JSON.stringify(output())}</span>
15+
</main>
16+
);
17+
}

0 commit comments

Comments
 (0)