Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/server-function-diagnostics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@solidjs/start": patch
---

Report server functions that cannot work instead of compiling them into broken output.

- A `"use server"` function that reads a variable from an enclosing function now fails the build. The function is moved to the top level of its module, so the variable is not in scope when it runs.
- The same check covers `this` and `arguments` in an arrow function, `super`, and private class members.
- A `"use server"` directive in an object or class method now fails the build. It was ignored before, which shipped the method body and the modules it imports to the browser.
- A `"use server"` string that is not the first statement of a module or a function body now logs a warning. It has no effect there.
- An export a `"use server"` module cannot serve now logs a warning that names it. These exports are still left out of the client build.
- A `"use server"` module can now export an anonymous default function. Both `export default async () => {}` and `export default async function () {}` work.
- Server function ids are now built from the names a function is nested under, such as `Page.load`, instead of the order the functions appear in. An id no longer changes when another server function is added to the same file, and two functions that share a name are told apart by the names around them. Production ids stay opaque.
- Server functions are now compiled in `.mts` and `.cts` files.
- Build errors now point at the full path of the file, not just its name.
Loading
Loading