Skip to content

Commit 9d3cbec

Browse files
lxsmnsycclaudebrenelz
authored
fix(directives): report server functions that cannot work (#2318)
Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Brenley Dueck <brenleydueck@gmail.com>
1 parent 378cbcd commit 9d3cbec

8 files changed

Lines changed: 1017 additions & 201 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
Report server functions that cannot work instead of compiling them into broken output.
6+
7+
- 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.
8+
- The same check covers `this` and `arguments` in an arrow function, `super`, and private class members.
9+
- 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.
10+
- 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.
11+
- 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.
12+
- A `"use server"` module can now export an anonymous default function. Both `export default async () => {}` and `export default async function () {}` work.
13+
- 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.
14+
- Server functions are now compiled in `.mts` and `.cts` files.
15+
- Build errors now point at the full path of the file, not just its name.

0 commit comments

Comments
 (0)