diff --git a/examples/server-actions/package.json b/examples/server-actions/package.json new file mode 100644 index 00000000..d9569791 --- /dev/null +++ b/examples/server-actions/package.json @@ -0,0 +1,14 @@ +{ + "name": "server-actions-example", + "type": "module", + "exports": { + "./inline": "./dist/inline.js", + "./client": "./dist/client.js" + }, + "devDependencies": { + "@types/react": "*" + }, + "dependencies": { + "react": "*" + } +} diff --git a/examples/server-actions/src/action.ts b/examples/server-actions/src/action.ts new file mode 100644 index 00000000..68e5c17a --- /dev/null +++ b/examples/server-actions/src/action.ts @@ -0,0 +1,5 @@ +'use server' + +export async function action1() { + return 'action1' +} diff --git a/examples/server-actions/src/client.tsx b/examples/server-actions/src/client.tsx new file mode 100644 index 00000000..779fbda2 --- /dev/null +++ b/examples/server-actions/src/client.tsx @@ -0,0 +1,7 @@ +'use client' + +import { action1 } from './action' + +export default function Page() { + return +} diff --git a/examples/server-actions/src/inline.tsx b/examples/server-actions/src/inline.tsx new file mode 100644 index 00000000..32b5e382 --- /dev/null +++ b/examples/server-actions/src/inline.tsx @@ -0,0 +1,11 @@ +// @ts-ignore externals +import ClientComponent from 'client-component' + +export default function Page() { + async function inlineAction() { + 'use server' + return 'inline-action' + } + + return +} diff --git a/examples/server-actions/tsconfig.json b/examples/server-actions/tsconfig.json new file mode 100644 index 00000000..b5fcf8f5 --- /dev/null +++ b/examples/server-actions/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "target": "ES2022" + } +}