Skip to content

Commit

Permalink
Fix SPA mode when single fetch is enabled (#9063)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Mar 19, 2024
1 parent 65f01d1 commit ce5cfe0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/single-fetch-spa-mode.md
@@ -0,0 +1,5 @@
---
"@remix-run/dev": patch
---

Fix SPA mode when single fetch is enabled by using streaming entry.server
3 changes: 2 additions & 1 deletion packages/remix-dev/cli/commands.ts
Expand Up @@ -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
? `entry.server.spa.tsx`
: `entry.server.${serverRuntime}.tsx`
);
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/config.ts
Expand Up @@ -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) {
// This is a super-simple default since we don't need streaming in SPA Mode.
// We can include this in a remix-spa template, but right now `npx remix reveal`
// will still expose the streaming template since that command doesn't have
Expand Down
5 changes: 4 additions & 1 deletion packages/remix-dev/config/defaults/entry.server.node.tsx
Expand Up @@ -15,7 +15,10 @@ export default function handleRequest(
remixContext: EntryContext,
loadContext: AppLoadContext
) {
return isBotRequest(request.headers.get("user-agent"))
let prohibitOutOfOrderStreaming =
isBotRequest(request.headers.get("user-agent")) || remixContext.isSpaMode;

return prohibitOutOfOrderStreaming
? handleBotRequest(
request,
responseStatusCode,
Expand Down
6 changes: 6 additions & 0 deletions templates/spa/app/entry.client.tsx
@@ -1,3 +1,9 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
Expand Down
19 changes: 0 additions & 19 deletions templates/spa/app/entry.server.tsx

This file was deleted.

0 comments on commit ce5cfe0

Please sign in to comment.