-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server action compiler error is thrown when graphql
relay tags are used
#65763
Comments
Could you try one thing, move the export async function setValue(string: string): Promise<void> {
'use server';
// comment out the next two statements to successfully compile Why? Well, it has been a while now, but IIRC, relay, pre-processes the file, and adds more code to it, that might be pushing down the // for example after relay processes the file we might have
import someRelayStuff from './folder-made-by-the-relay-compiler';
// more of those
'use server';
import { revalidatePath } from "next/cache"; And that causes the issue you are seeing. We can try to confirm this by placing the |
moving the directive inside the function results in this error:
|
Not on my laptop now, but are you importing this function directly into a client module (use client)? If so, import it to a server component instead and pass it down as props, just to test if all of this makes it work... We are exploring the issue. |
my bad, yes moving it into the RSC works |
Alright, but then maybe this is something that Relay should fix, as in, respect, or check for, the presence of |
It's a bug of SWC relay plugin |
eagerEsModules: true, was the cause |
swc-project/plugins#306 should fix it |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/jgeschwendt/repro-next-relay-server-action
To Reproduce
using the following relay code in a server action:
https://github.com/jgeschwendt/repro-next-relay-server-action/blob/test/src/app/actions.ts#L8-L16
causes this error:
reproduced in GitHub Actions:
https://github.com/jgeschwendt/repro-next-relay-server-action/actions/workflows/ci.yaml
Current vs. Expected behavior
I am able to use the relay compiled tagged node in a server action
Provide environment information
GitHub: `ubuntu-latest` Node: 20 pnpm: 9 Next.js: 14.2.3
Which area(s) are affected? (Select all that apply)
Not sure, SWC
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: