Skip to content

Omit route components from non-SSR builds when ssr: false#1481

Merged
ryansolid merged 4 commits intosolidjs:mainfrom
Brendonovich:dataOnly-routes-when-CSR
May 20, 2024
Merged

Omit route components from non-SSR builds when ssr: false#1481
ryansolid merged 4 commits intosolidjs:mainfrom
Brendonovich:dataOnly-routes-when-CSR

Conversation

@Brendonovich
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • infrastructure changes
  • Other... Please describe:

What is the current behavior?

When building with ssr: false, the ssr + server-fn builds still transform + bundle all of the route components in filesystem routes.
This doesn't really make sense, since the ssr build will only ever be used during prerendering, which just renders entry-server.tsx and app.tsx, and server-fn only invokes App with dataOnly set on the router so none of the route components are actually used.

What is the new behavior?

This PR adds a dataOnly config to SolidStartServerFileRouter which makes it omit the default exported component from all routes. Non-default exported components work the same and export const route is still included since it's needed on the server for SFM.

Other information

@changeset-bot
Copy link

changeset-bot bot commented May 18, 2024

🦋 Changeset detected

Latest commit: c904644

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

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

@Brendonovich Brendonovich changed the title Omit route components from non-SSR workloads Omit route components from non-SSR builds when ssr: false May 18, 2024
@ryansolid
Copy link
Member

That's awesome.. Thank you. I was meaning to look at this and I'm pretty stoked that you applied this optimization.

@ryansolid ryansolid merged commit 9348ace into solidjs:main May 20, 2024
@ryansolid
Copy link
Member

Hmm.. it breaks the notes demo. It is no longer single flight in SSR false. Which suggests something isn't working the way it should. I will see if I can figure it out in the next 30 mins otherwise moving forward with the release I might have to temporarily revert this.

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