Skip to content

fix(directives): report server functions that cannot work - #2318

Merged
brenelz merged 3 commits into
mainfrom
fix/server-function-diagnostics
Sep 18, 2026
Merged

brenelz merged 3 commits into
mainfrom
fix/server-function-diagnostics

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

A server function is moved to the top level of its module, and several shapes stop working once it is. They compiled without complaint before.

  • Fail the build when a server function reads a variable from an enclosing function, uses this or arguments in an arrow, uses super, or reads a private class member.
  • Fail the build when the directive is in an object or class method. The transform ignored it, which shipped the method body and the modules it imports to the browser.
  • Warn when a directive string is not the first statement of a module or a function body, where it has no effect.
  • Warn for each export a "use server" module cannot serve, naming it. Those exports are still left out of the client build.
  • Support an anonymous default export from a "use server" module.
  • Compile server functions in .mts and .cts files.
  • Point build errors at the full path of the file.

A server function is moved to the top level of its module, and several
shapes stop working once it is. They compiled without complaint before.

- Fail the build when a server function reads a variable from an enclosing
  function, uses `this` or `arguments` in an arrow, uses `super`, or reads a
  private class member.
- Fail the build when the directive is in an object or class method. The
  transform ignored it, which shipped the method body and the modules it
  imports to the browser.
- Warn when a directive string is not the first statement of a module or a
  function body, where it has no effect.
- Warn for each export a "use server" module cannot serve, naming it. Those
  exports are still left out of the client build.
- Support an anonymous default export from a "use server" module.
- Compile server functions in `.mts` and `.cts` files.
- Point build errors at the full path of the file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 47d2db5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Sep 11, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 47d2db5
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6aac94a0a767bb00088a0214
😎 Deploy Preview https://deploy-preview-2318--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@solidjs/start@2318

commit: 47d2db5

Ids were the position of the function in the file, so adding a server
function renumbered every later one. A client bundle from an earlier build
then called a different function instead of failing.

- Build the id from the names the function is nested under, such as
  `Page.load`. Functions that share a name path are numbered.
- Keep production ids opaque by hashing that name.
- Drop `get-descriptive-name.ts`, which nothing uses now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lxsmnsyc

Copy link
Copy Markdown
Member Author

Also replaces the getDescriptiveName for getHierarchicalName, which fixes an issue where two server functions of the same name but of different scopes (e.g. FooComponent > foo vs BarComponent > foo) gets a compiler conflict since the generated ids matches .

@brenelz
brenelz merged commit 9d3cbec into main Sep 18, 2026
13 of 14 checks passed
@brenelz
brenelz deleted the fix/server-function-diagnostics branch September 18, 2026 01:36
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

Successfully merging this pull request may close these issues.

2 participants