Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SPA mode when single fetch is enabled #9063

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Mar 15, 2024

We can't use renderToString when single fetch is enabled, so don't default to (or reveal) entry.server.spa.tsx in SPA mode if single fetch is enabled.

I also removed the entry.server.tsx file from templates/spa since there's no need for the user to customize it like there may be in non-SPA templates.

Copy link

changeset-bot bot commented Mar 15, 2024

🦋 Changeset detected

Latest commit: 1037483

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

This PR includes changesets to release 16 packages
Name Type
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing 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

@@ -303,7 +303,8 @@ export async function generateEntry(
let defaultEntryClient = path.resolve(defaultsDirectory, "entry.client.tsx");
let defaultEntryServer = path.resolve(
defaultsDirectory,
ctx?.remixConfig.ssr === false
ctx?.remixConfig.ssr === false &&
ctx?.remixConfig.future.unstable_singleFetch !== true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reveal the streaming entry.server in SPA mode when single fetch is enabled.

I wonder if there's any good way to detect if a user is currently using renderToString in their own entry.server and they flip on single fetch. From what I recall the error isn't super obvious and React sticks it in a <template> at the end of the HTML but no console errors get logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacob-ebey is going to look into a check at built time for this using the entry.server AST (separate PR)

@@ -469,7 +469,7 @@ export async function resolveConfig(
let pkgJson = await PackageJson.load(rootDirectory);
let deps = pkgJson.content.dependencies ?? {};

if (isSpaMode) {
if (isSpaMode && appConfig.future?.unstable_singleFetch != true) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default to the streaming entry server in SPA mode w/singleFetch if the user doesn't have an entry.server

@brophdawg11 brophdawg11 merged commit ce5cfe0 into dev Mar 19, 2024
9 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/spa-mode-single-fetch branch March 19, 2024 15:13
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release This issue has been fixed and will be released soon CLA Signed feat:routing feat:spa Issues related to SPA Mode package:dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants