-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(server-functions): add module level directive tests (#1739)
- Loading branch information
Showing
12 changed files
with
107 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use server"; | ||
|
||
import { isServer } from "solid-js/web"; | ||
|
||
export function serverFnWithIsServer() { | ||
return isServer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use server"; | ||
|
||
import { join } from 'node:path'; | ||
|
||
export function serverFnWithNodeBuiltin() { | ||
|
||
return join('can','externalize'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use server"; | ||
|
||
import _ from 'lodash'; | ||
|
||
export function serverFnWithNpmModule() { | ||
|
||
return _.map([1, 2, 3], x => x * 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
.../server-function/src/routes/is-server.tsx → ...-function/src/routes/is-server-nested.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createEffect, createSignal } from "solid-js"; | ||
import { serverFnWithIsServer } from "~/functions/use-is-server"; | ||
|
||
export default function App() { | ||
const [output, setOutput] = createSignal<{ serverFnWithIsServer?: boolean }>({}); | ||
|
||
|
||
createEffect(async () => { | ||
const restult = await serverFnWithIsServer(); | ||
setOutput(prev => ({ ...prev, serverFnWithIsServer: restult })); | ||
}); | ||
|
||
|
||
return ( | ||
<main> | ||
<span id="server-fn-test">{JSON.stringify(output())}</span> | ||
</main> | ||
); | ||
} |
4 changes: 1 addition & 3 deletions
4
...rver-function/src/routes/node-builtin.tsx → ...nction/src/routes/node-builtin-nested.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/server-function/src/routes/node-builtin-toplevel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import { createEffect, createSignal } from "solid-js"; | ||
import { serverFnWithNodeBuiltin } from "~/functions/use-node-builtin"; | ||
|
||
export default function App() { | ||
const [output, setOutput] = createSignal<{ serverFnWithNodeBuiltin?: string }>({}); | ||
|
||
createEffect(async () => { | ||
const restult = await serverFnWithNodeBuiltin(); | ||
setOutput(prev => ({ ...prev, serverFnWithNodeBuiltin: restult })); | ||
}); | ||
|
||
return ( | ||
<main> | ||
<span id="server-fn-test">{JSON.stringify(output())}</span> | ||
</main> | ||
); | ||
} |
2 changes: 0 additions & 2 deletions
2
...server-function/src/routes/npm-module.tsx → ...function/src/routes/npm-module-nested.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createEffect, createSignal } from "solid-js"; | ||
import { serverFnWithNpmModule } from "~/functions/use-npm-module"; | ||
|
||
export default function App() { | ||
const [output, setOutput] = createSignal<{ serverFnWithNpmModule?: number[] }>({}); | ||
|
||
createEffect(async () => { | ||
const restult = await serverFnWithNpmModule(); | ||
setOutput(prev => ({ ...prev, serverFnWithNpmModule: restult })); | ||
}); | ||
|
||
return ( | ||
<main> | ||
<span id="server-fn-test">{JSON.stringify(output())}</span> | ||
</main> | ||
); | ||
} |