Skip to content

Commit 0c9bc47

Browse files
authored
fix: anonymous default exports with server functions (#1808)
1 parent 9b6ba7f commit 0c9bc47

File tree

7 files changed

+379
-335
lines changed

7 files changed

+379
-335
lines changed

.changeset/lovely-comics-hammer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Fix issue with anonymous default exports

packages/start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"dependencies": {
6666
"@vinxi/plugin-directives": "^0.5.0",
6767
"@vinxi/server-components": "^0.5.0",
68-
"@tanstack/server-functions-plugin": "^1.103.1",
68+
"@tanstack/server-functions-plugin": "^1.105.2",
6969
"defu": "^6.1.2",
7070
"error-stack-parser": "^2.1.4",
7171
"html-to-image": "^1.11.11",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ describe("server-function", () => {
4848
.its("status")
4949
.should("eq", 404);
5050
});
51+
it("should build when anon default export and server functions", () => {
52+
cy.visit("is-server-with-anon-default-export");
53+
cy.get("#server-fn-test").contains('{"serverFnWithIsServer":true}');
54+
});
5155
});

packages/tests/src/app.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default function App() {
4141
<li>
4242
<a href="/treeshaking/side-effects">treeshaking (w/ side-effects)</a>
4343
</li>
44+
<li>
45+
<a href="/is-server-with-anon-default-export">is server with anon default export</a>
46+
</li>
4447
</ul>
4548
<Suspense>{props.children}</Suspense>
4649
</MetaProvider>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { isServer } from "solid-js/web";
2+
3+
export function serverFnWithIsServer() {
4+
"use server";
5+
return isServer;
6+
}
7+
8+
export default function () {
9+
return null;
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { createEffect, createSignal } from "solid-js";
2+
import { serverFnWithIsServer } from "~/functions/use-is-server-with-anon-default-export";
3+
4+
export default function App() {
5+
const [output, setOutput] = createSignal<{ serverFnWithIsServer?: boolean }>({});
6+
7+
8+
createEffect(async () => {
9+
const restult = await serverFnWithIsServer();
10+
setOutput(prev => ({ ...prev, serverFnWithIsServer: restult }));
11+
});
12+
13+
14+
return (
15+
<main>
16+
<span id="server-fn-test">{JSON.stringify(output())}</span>
17+
</main>
18+
);
19+
}

0 commit comments

Comments
 (0)