Skip to content

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

Open
lxsmnsyc wants to merge 2 commits into
mainfrom
fix/server-function-diagnostics
Open

fix(directives): report server functions that cannot work#2318
lxsmnsyc wants to merge 2 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: b0ddee2

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 b0ddee2
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6aa3a16b6475310008dc97ea
😎 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: b0ddee2

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 .

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.

1 participant