Skip to content

fix(server): keep the API route matcher out of the client bundle - #2362

Open
lxsmnsyc wants to merge 1 commit into
mainfrom
fix/client-api-router
Open

lxsmnsyc wants to merge 1 commit into
mainfrom
fix/client-api-router

Conversation

@lxsmnsyc

Copy link
Copy Markdown
Member

The client imports pageRoutes from server/routes.ts, and that module also built the radix3 API router at load time. The bundler could not drop that call, so radix3 and the router code shipped to the browser. The client route manifest has no API handlers, so that router was always empty there.

Fixes #2361.

Changes

  • Move the API router, containsHTTP and matchAPIRoute into a new server-only server/api-routes.ts.
  • Keep only pageRoutes in server/routes.ts.
  • Match routes that only export an OPTIONS handler. HTTP_METHODS includes OPTIONS, but containsHTTP did not check $OPTIONS, so those routes were never added to the router.
  • Rename routes.spec.ts to api-routes.spec.ts and add a test for an OPTIONS-only route.
  • Add treeshaking/api-router.server.test.ts. It checks that the router is in the server output and not in any client file.

Testing

  • packages/start: tsc --noEmit passes and all 267 unit tests pass.
  • apps/tests: built the app and ran the node tests. All pass.
  • With the old routes.ts restored, the new build test fails because entry-client contains the router.
  • Client output in apps/tests drops from 147,161 to 144,643 bytes. This matches the 2.5 KB difference reported in the issue.

🤖 Generated with Claude Code

- Move the radix3 API router and matchAPIRoute into a server-only api-routes.ts.
- routes.ts keeps only pageRoutes, which the client needs.
- Match routes that only export an OPTIONS handler.
- Add a build test that checks the router is not in client output.

Fixes #2361

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit c928b9c
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6ad9580d6d0829abd54328fa
😎 Deploy Preview https://deploy-preview-2362--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.

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c928b9c

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: c928b9c

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.

[Bug?]: Page-only client bundle retains the server API route matcher

1 participant