Skip to content

Commit f5656c3

Browse files
authored
Merge pull request trykimu#5 from florentpergoud/chore/deps/update-dependencies
2 parents b168c10 + 4cf7646 commit f5656c3

7 files changed

Lines changed: 219 additions & 95 deletions

File tree

app/entry.client.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
import { RemixBrowser } from '@remix-run/react';
2-
import { hydrateRoot } from 'react-dom/client';
1+
/**
2+
* By default, Remix will handle hydrating your app on the client for you.
3+
* 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` ✨
4+
* For more information, see https://remix.run/file-conventions/entry.client
5+
*/
36

4-
hydrateRoot(document, <RemixBrowser />);
7+
import { RemixBrowser } from "@remix-run/react";
8+
import { startTransition, StrictMode } from "react";
9+
import { hydrateRoot } from "react-dom/client";
10+
11+
startTransition(() => {
12+
hydrateRoot(
13+
document,
14+
<StrictMode>
15+
<RemixBrowser />
16+
</StrictMode>
17+
);
18+
});

app/entry.server.tsx

Lines changed: 135 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,140 @@
1-
import type { EntryContext } from '@remix-run/node';
2-
import { Response } from '@remix-run/node';
3-
import { RemixServer } from '@remix-run/react';
4-
import { renderToPipeableStream } from 'react-dom/server';
5-
import { PassThrough } from 'stream';
1+
/**
2+
* By default, Remix will handle generating the HTTP Response for you.
3+
* 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` ✨
4+
* For more information, see https://remix.run/file-conventions/entry.server
5+
*/
66

7-
const ABORT_DELAY = 5000;
7+
import { PassThrough } from "node:stream";
8+
9+
import type { AppLoadContext, EntryContext } from "@remix-run/node";
10+
import { createReadableStreamFromReadable } from "@remix-run/node";
11+
import { RemixServer } from "@remix-run/react";
12+
import { isbot } from "isbot";
13+
import { renderToPipeableStream } from "react-dom/server";
14+
15+
const ABORT_DELAY = 5_000;
816

917
export default function handleRequest(
10-
request: Request,
11-
responseStatusCode: number,
12-
responseHeaders: Headers,
13-
remixContext: EntryContext
18+
request: Request,
19+
responseStatusCode: number,
20+
responseHeaders: Headers,
21+
remixContext: EntryContext,
22+
// This is ignored so we can keep it in the template for visibility. Feel
23+
// free to delete this parameter in your app if you're not using it!
24+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25+
loadContext: AppLoadContext
26+
) {
27+
return isbot(request.headers.get("user-agent") || "")
28+
? handleBotRequest(
29+
request,
30+
responseStatusCode,
31+
responseHeaders,
32+
remixContext
33+
)
34+
: handleBrowserRequest(
35+
request,
36+
responseStatusCode,
37+
responseHeaders,
38+
remixContext
39+
);
40+
}
41+
42+
function handleBotRequest(
43+
request: Request,
44+
responseStatusCode: number,
45+
responseHeaders: Headers,
46+
remixContext: EntryContext
47+
) {
48+
return new Promise((resolve, reject) => {
49+
let shellRendered = false;
50+
const { pipe, abort } = renderToPipeableStream(
51+
<RemixServer
52+
context={remixContext}
53+
url={request.url}
54+
abortDelay={ABORT_DELAY}
55+
/>,
56+
{
57+
onAllReady() {
58+
shellRendered = true;
59+
const body = new PassThrough();
60+
const stream = createReadableStreamFromReadable(body);
61+
62+
responseHeaders.set("Content-Type", "text/html");
63+
64+
resolve(
65+
new Response(stream, {
66+
headers: responseHeaders,
67+
status: responseStatusCode,
68+
})
69+
);
70+
71+
pipe(body);
72+
},
73+
onShellError(error: unknown) {
74+
reject(error);
75+
},
76+
onError(error: unknown) {
77+
responseStatusCode = 500;
78+
// Log streaming rendering errors from inside the shell. Don't log
79+
// errors encountered during initial shell rendering since they'll
80+
// reject and get logged in handleDocumentRequest.
81+
if (shellRendered) {
82+
console.error(error);
83+
}
84+
},
85+
}
86+
);
87+
88+
setTimeout(abort, ABORT_DELAY);
89+
});
90+
}
91+
92+
function handleBrowserRequest(
93+
request: Request,
94+
responseStatusCode: number,
95+
responseHeaders: Headers,
96+
remixContext: EntryContext
1497
) {
15-
return new Promise((resolve, reject) => {
16-
let didError = false;
17-
18-
const { pipe, abort } = renderToPipeableStream(
19-
<RemixServer context={remixContext} url={request.url} />,
20-
{
21-
onShellReady: () => {
22-
const body = new PassThrough();
23-
24-
responseHeaders.set('Content-Type', 'text/html');
25-
26-
resolve(
27-
new Response(body, {
28-
headers: responseHeaders,
29-
status: didError ? 500 : responseStatusCode,
30-
})
31-
);
32-
33-
pipe(body);
34-
},
35-
onShellError: (err) => {
36-
reject(err);
37-
},
38-
onError: (error) => {
39-
didError = true;
40-
41-
console.error(error);
42-
},
43-
}
44-
);
45-
46-
setTimeout(abort, ABORT_DELAY);
47-
});
98+
return new Promise((resolve, reject) => {
99+
let shellRendered = false;
100+
const { pipe, abort } = renderToPipeableStream(
101+
<RemixServer
102+
context={remixContext}
103+
url={request.url}
104+
abortDelay={ABORT_DELAY}
105+
/>,
106+
{
107+
onShellReady() {
108+
shellRendered = true;
109+
const body = new PassThrough();
110+
const stream = createReadableStreamFromReadable(body);
111+
112+
responseHeaders.set("Content-Type", "text/html");
113+
114+
resolve(
115+
new Response(stream, {
116+
headers: responseHeaders,
117+
status: responseStatusCode,
118+
})
119+
);
120+
121+
pipe(body);
122+
},
123+
onShellError(error: unknown) {
124+
reject(error);
125+
},
126+
onError(error: unknown) {
127+
responseStatusCode = 500;
128+
// Log streaming rendering errors from inside the shell. Don't log
129+
// errors encountered during initial shell rendering since they'll
130+
// reject and get logged in handleDocumentRequest.
131+
if (shellRendered) {
132+
console.error(error);
133+
}
134+
},
135+
}
136+
);
137+
138+
setTimeout(abort, ABORT_DELAY);
139+
});
48140
}

app/root.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import {
88
ScrollRestoration,
99
} from '@remix-run/react';
1010

11-
export const meta: MetaFunction = () => ({
12-
charset: 'utf-8',
13-
title: 'Remotion + Remix',
14-
viewport: 'width=device-width,initial-scale=1',
15-
});
16-
11+
export const meta: MetaFunction = () => {
12+
return [
13+
{ charset: 'utf-8' },
14+
{ name: 'viewport', content: 'width=device-width,initial-scale=1' },
15+
{ property: 'og:title', content: 'Remotion + Remix' },
16+
];
17+
};
1718
export default function App() {
1819
return (
1920
<html lang="en">

package.json

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,57 @@
11
{
22
"private": true,
3+
"type": "module",
34
"scripts": {
45
"build": "remix build",
5-
"dev": "remix dev",
6-
"start": "remix-serve build",
6+
"dev": "remix dev --manual",
7+
"lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
8+
"start": "remix-serve ./build/index.js",
9+
"typecheck": "tsc",
710
"test": "eslint app --ext ts,tsx,js,jsx && tsc",
811
"remotion:studio": "remotion studio",
912
"remotion:render": "remotion render LogoAnimation out/logo-animation.mp4",
1013
"remotion:upgrade": "remotion upgrade",
1114
"remotion:renderlambda": "remotion lambda render remotion-remix-example LogoAnimation out/logo-animation-lambda-rendered.mp4",
1215
"remotion:deploy": "ts-node app/deploy.ts"
1316
},
17+
"engines": {
18+
"node": ">=18"
19+
},
20+
"sideEffects": [
21+
"*.css"
22+
],
1423
"dependencies": {
15-
"@remix-run/node": "^1.7.2",
16-
"@remix-run/react": "^1.7.2",
17-
"@remix-run/serve": "^1.7.2",
24+
"@remix-run/css-bundle": "^2.6.0",
25+
"@remix-run/node": "^2.6.0",
26+
"@remix-run/react": "^2.6.0",
27+
"@remix-run/serve": "^2.6.0",
1828
"@remix-run/vercel": "^1.9.0",
1929
"@remotion/cli": "^4.0.0",
2030
"@remotion/lambda": "^4.0.0",
2131
"@remotion/player": "^4.0.0",
22-
"@vercel/node": "^2.8.1",
32+
"@vercel/remix": "2.5.1",
2333
"react": "^18.2.0",
2434
"react-dom": "^18.2.0",
25-
"remotion": "^4.0.0"
35+
"remotion": "^4.0.0",
36+
"isbot": "^4.1.0"
2637
},
2738
"devDependencies": {
28-
"@remix-run/dev": "^1.9.0",
29-
"@remix-run/eslint-config": "^1.9.0",
39+
"@remix-run/dev": "v2.6.0",
40+
"@remix-run/eslint-config": "v2.6.0",
3041
"@remotion/eslint-plugin": "^4.0.0",
31-
"@types/react": "^18.0.26",
32-
"@types/react-dom": "^18.0.10",
42+
"@types/node": ">= 18",
43+
"@types/react": "^18.2.20",
44+
"@types/react-dom": "^18.2.7",
3345
"dotenv": "^16.0.3",
34-
"eslint": "^8.43.0",
35-
"prettier": "^2.8.8",
46+
"eslint": "^8.38.0",
47+
"prettier": "^3.2.5",
3648
"ts-node": "^10.9.1",
37-
"typescript": "^4.9.4",
38-
"@types/node": ">= 14"
39-
},
40-
"engines": {
41-
"node": ">=14"
42-
},
43-
"sideEffects": [
44-
"*.css"
45-
]
49+
"typescript": "^5.1.6",
50+
"@typescript-eslint/eslint-plugin": "^6.7.4",
51+
"eslint-import-resolver-typescript": "^3.6.1",
52+
"eslint-plugin-import": "^2.28.1",
53+
"eslint-plugin-jsx-a11y": "^6.7.1",
54+
"eslint-plugin-react": "^7.33.2",
55+
"eslint-plugin-react-hooks": "^4.6.0"
56+
}
4657
}

remix.config.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
/** @type {import('@remix-run/dev').AppConfig} */
2-
module.exports = {
3-
serverBuildTarget: 'vercel',
4-
// When running locally in development mode, we use the built in remix
5-
// server. This does not understand the vercel lambda module format,
6-
// so we default back to the standard build output.
7-
server: process.env.NODE_ENV === 'development' ? undefined : './server.js',
8-
ignoredRouteFiles: ['**/.*'],
9-
// appDirectory: "app",
10-
// assetsBuildDirectory: "public/build",
11-
// serverBuildPath: "api/index.js",
12-
// publicPath: "/build/",
2+
export default {
3+
ignoredRouteFiles: ["**/.*"],
4+
// appDirectory: "app",
5+
// assetsBuildDirectory: "public/build",
6+
// publicPath: "/build/",
7+
// serverBuildPath: "build/index.js",
138
};

tsconfig.json

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
{
2-
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
2+
"include": [
3+
"remix.env.d.ts",
4+
"**/*.ts",
5+
"**/*.tsx"
6+
],
37
"compilerOptions": {
4-
"lib": ["DOM", "DOM.Iterable", "ES2019"],
8+
"lib": [
9+
"DOM",
10+
"DOM.Iterable",
11+
"ES2022"
12+
],
513
"isolatedModules": true,
614
"esModuleInterop": true,
715
"jsx": "react-jsx",
8-
"moduleResolution": "node",
16+
"moduleResolution": "Bundler",
917
"resolveJsonModule": true,
10-
"target": "ES2019",
18+
"target": "ES2022",
1119
"strict": true,
1220
"allowJs": true,
13-
"forceConsistentCasingInFileNames": true,
14-
"noImplicitAny": true,
15-
"noUnusedLocals": true,
16-
"noUnusedParameters": true,
17-
"noEmit": true,
1821
"skipLibCheck": true,
19-
"baseUrl": "."
22+
"forceConsistentCasingInFileNames": true,
23+
"baseUrl": ".",
24+
"paths": {
25+
"~/*": [
26+
"./app/*"
27+
]
28+
},
29+
// Remix takes care of building everything in `remix build`.
30+
"noEmit": true
2031
}
2132
}

0 commit comments

Comments
 (0)