-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable ServerDirective transform and add test case
- Loading branch information
Showing
8 changed files
with
89 additions
and
3 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
5 changes: 5 additions & 0 deletions
5
...next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.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,5 @@ | ||
'use server' | ||
|
||
export default async function Action() { | ||
return 42 | ||
} |
7 changes: 7 additions & 0 deletions
7
...next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/layout.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,7 @@ | ||
export default function RootLayout({ children }: { children: any }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
...s/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/page.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,15 @@ | ||
import Test from './test' | ||
|
||
export default async function Page() { | ||
let action | ||
try { | ||
await import('./action') | ||
} catch (e) { | ||
action = e.toString() | ||
} | ||
return ( | ||
<div> | ||
<Test action={action} /> | ||
</div> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
...s/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/test.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,23 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
|
||
export default function Test({ action }) { | ||
useEffect(() => { | ||
import('@turbo/pack-test-harness').then(() => { | ||
it('should run', () => {}) | ||
it('should throw an error when importing server action in client component', async () => { | ||
await expect(import('./action')).rejects.toMatchObject({ | ||
message: | ||
/Server actions \("use server"\) are not yet supported in Turbopack/, | ||
}) | ||
}) | ||
it('should throw an error when importing server action in server component', () => { | ||
expect(action).toMatch( | ||
/Server actions \("use server"\) are not yet supported in Turbopack/ | ||
) | ||
}) | ||
}) | ||
return () => {} | ||
}, [action]) | ||
} |
5 changes: 5 additions & 0 deletions
5
...next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/next.config.js
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,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
}; |
21 changes: 21 additions & 0 deletions
21
...s/Server actions (__quo__use server__quo__) are not yet supported in Turbopack-4c3b2b.txt
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,21 @@ | ||
PlainIssue { | ||
severity: Error, | ||
context: "[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app/action.tsx", | ||
category: "unsupported", | ||
title: "Server actions (\"use server\") are not yet supported in Turbopack", | ||
description: "", | ||
detail: "", | ||
documentation_link: "", | ||
source: None, | ||
sub_issues: [], | ||
processing_path: Some( | ||
[ | ||
PlainIssueProcessingPathItem { | ||
context: Some( | ||
"[project]/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/use-server/input/app", | ||
), | ||
description: "Next.js App Page Route /", | ||
}, | ||
], | ||
), | ||
} |