From 4ef417d137199640f07c3e22b7fc76b74ec10c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 16 Mar 2023 00:21:15 +0100 Subject: [PATCH] feat: remove `entry.*.ts` files --- app/entry.client.tsx | 22 ------------------ app/entry.server.tsx | 53 -------------------------------------------- 2 files changed, 75 deletions(-) delete mode 100644 app/entry.client.tsx delete mode 100644 app/entry.server.tsx diff --git a/app/entry.client.tsx b/app/entry.client.tsx deleted file mode 100644 index 1d4ba68..0000000 --- a/app/entry.client.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { RemixBrowser } from "@remix-run/react"; -import { startTransition, StrictMode } from "react"; -import { hydrateRoot } from "react-dom/client"; - -const hydrate = () => { - startTransition(() => { - hydrateRoot( - document, - - - - ); - }); -}; - -if (window.requestIdleCallback) { - window.requestIdleCallback(hydrate); -} else { - // Safari doesn't support requestIdleCallback - // https://caniuse.com/requestidlecallback - window.setTimeout(hydrate, 1); -} diff --git a/app/entry.server.tsx b/app/entry.server.tsx deleted file mode 100644 index 7b9fd91..0000000 --- a/app/entry.server.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { PassThrough } from "stream"; -import type { EntryContext } from "@remix-run/node"; -import { Response } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import isbot from "isbot"; -import { renderToPipeableStream } from "react-dom/server"; - -const ABORT_DELAY = 5000; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - const callbackName = isbot(request.headers.get("user-agent")) - ? "onAllReady" - : "onShellReady"; - - return new Promise((resolve, reject) => { - let didError = false; - - const { pipe, abort } = renderToPipeableStream( - , - { - [callbackName]: () => { - const body = new PassThrough(); - - responseHeaders.set("Content-Type", "text/html"); - - resolve( - new Response(body, { - headers: responseHeaders, - status: didError ? 500 : responseStatusCode, - }) - ); - - pipe(body); - }, - onShellError: (err: unknown) => { - reject(err); - }, - onError: (error: unknown) => { - didError = true; - - console.error(error); - }, - } - ); - - setTimeout(abort, ABORT_DELAY); - }); -}