Skip to content
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

"use server" breaks if export default used #84

Open
justinvdm opened this issue Feb 10, 2025 · 0 comments
Open

"use server" breaks if export default used #84

justinvdm opened this issue Feb 10, 2025 · 0 comments

Comments

@justinvdm
Copy link
Collaborator

justinvdm commented Feb 10, 2025

When using "use server", you're able to export, but not export default. Otherwise you'll see this when you pnpm build

src/app/pages/invoice/routes.ts (3:7): "default" is not exported by "src/app/pages/invoice/ListPage/InvoiceListPage.tsx", imported by "src/app/pages/invoice/routes.ts".
file: /Users/justin/rw/reloaded/experiments/billable/src/app/pages/invoice/routes.ts:3:7

1: import { db, index, route } from "@redwoodjs/reloaded/worker";
2: import InvoiceDetailPage from "./DetailPage/InvoiceDetailPage";
3: import InvoiceListPage from "./ListPage/InvoiceListPage";

This happens because of how we transform "use server" modules to wrap exports to register server-side actions. We need to either fix this, or if it makes sense to keep the restriction, catch it and provide understandable error message about what happened, how to fix it, and why it needs to be that way.

justinvdm added a commit that referenced this issue Feb 10, 2025
We currently have an issue with `"use server"` modules where we cannot use `export default`s, only `export`s.

This PR avoids the issue by changing the relevant `export default`s to `export`s. #84 tracks solving the actual issue for future cases.
justinvdm added a commit that referenced this issue Feb 10, 2025
We currently have an issue with `"use server"` modules where we cannot use `export default`s, only `export`s.

This PR avoids the issue by changing the relevant `export default`s to `export`s. #84 tracks solving the actual issue for future cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant