Skip to content

Commit c1066f7

Browse files
committed
feat: upgrade to Remix v2
1 parent af4c898 commit c1066f7

16 files changed

+61
-149
lines changed

app/entry.server.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
55
*/
66

7-
import { PassThrough } from "node:stream";
7+
import { PassThrough, Readable } from "node:stream";
88

99
import type { EntryContext } from "@remix-run/node";
10-
import { Response } from "@remix-run/node";
1110
import { RemixServer } from "@remix-run/react";
1211
import isbot from "isbot";
1312
import { renderToPipeableStream } from "react-dom/server";
@@ -55,7 +54,7 @@ function handleBotRequest(
5554
responseHeaders.set("Content-Type", "text/html");
5655

5756
resolve(
58-
new Response(body, {
57+
new Response(Readable.toWeb(body) as ReadableStream, {
5958
headers: responseHeaders,
6059
status: responseStatusCode,
6160
}),
@@ -97,7 +96,7 @@ function handleBrowserRequest(
9796
responseHeaders.set("Content-Type", "text/html");
9897

9998
resolve(
100-
new Response(body, {
99+
new Response(Readable.toWeb(body) as ReadableStream, {
101100
headers: responseHeaders,
102101
status: responseStatusCode,
103102
}),

app/root.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cssBundleHref } from "@remix-run/css-bundle";
2-
import type { LinksFunction, LoaderArgs } from "@remix-run/node";
2+
import type { LinksFunction, LoaderFunctionArgs } from "@remix-run/node";
33
import { json } from "@remix-run/node";
44
import {
55
Links,
@@ -20,7 +20,7 @@ export const links: LinksFunction = () => [
2020
{ rel: "icon", href: "/_static/favicon.ico" },
2121
];
2222

23-
export const loader = async ({ request }: LoaderArgs) => {
23+
export const loader = async ({ request }: LoaderFunctionArgs) => {
2424
return json({ user: await getUser(request) });
2525
};
2626

app/routes/_index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { V2_MetaFunction } from "@remix-run/node";
1+
import type { MetaFunction } from "@remix-run/node";
22
import { Link } from "@remix-run/react";
33

44
import { useOptionalUser } from "~/utils";
55

6-
export const meta: V2_MetaFunction = () => [{ title: "Remix Notes" }];
6+
export const meta: MetaFunction = () => [{ title: "Remix Notes" }];
77

88
export default function Index() {
99
const user = useOptionalUser();

app/routes/join.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ActionArgs, LoaderArgs, V2_MetaFunction } from "@remix-run/node";
1+
import type {
2+
ActionFunctionArgs,
3+
LoaderFunctionArgs,
4+
MetaFunction,
5+
} from "@remix-run/node";
26
import { json, redirect } from "@remix-run/node";
37
import { Form, Link, useActionData, useSearchParams } from "@remix-run/react";
48
import { useEffect, useRef } from "react";
@@ -7,13 +11,13 @@ import { createUser, getUserByEmail } from "~/models/user.server";
711
import { createUserSession, getUserId } from "~/session.server";
812
import { safeRedirect, validateEmail } from "~/utils";
913

10-
export const loader = async ({ request }: LoaderArgs) => {
14+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1115
const userId = await getUserId(request);
1216
if (userId) return redirect("/");
1317
return json({});
1418
};
1519

16-
export const action = async ({ request }: ActionArgs) => {
20+
export const action = async ({ request }: ActionFunctionArgs) => {
1721
const formData = await request.formData();
1822
const email = formData.get("email");
1923
const password = formData.get("password");
@@ -63,7 +67,7 @@ export const action = async ({ request }: ActionArgs) => {
6367
});
6468
};
6569

66-
export const meta: V2_MetaFunction = () => [{ title: "Sign Up" }];
70+
export const meta: MetaFunction = () => [{ title: "Sign Up" }];
6771

6872
export default function Join() {
6973
const [searchParams] = useSearchParams();

app/routes/login.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ActionArgs, LoaderArgs, V2_MetaFunction } from "@remix-run/node";
1+
import type {
2+
ActionFunctionArgs,
3+
LoaderFunctionArgs,
4+
MetaFunction,
5+
} from "@remix-run/node";
26
import { json, redirect } from "@remix-run/node";
37
import { Form, Link, useActionData, useSearchParams } from "@remix-run/react";
48
import { useEffect, useRef } from "react";
@@ -7,13 +11,13 @@ import { verifyLogin } from "~/models/user.server";
711
import { createUserSession, getUserId } from "~/session.server";
812
import { safeRedirect, validateEmail } from "~/utils";
913

10-
export const loader = async ({ request }: LoaderArgs) => {
14+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1115
const userId = await getUserId(request);
1216
if (userId) return redirect("/");
1317
return json({});
1418
};
1519

16-
export const action = async ({ request }: ActionArgs) => {
20+
export const action = async ({ request }: ActionFunctionArgs) => {
1721
const formData = await request.formData();
1822
const email = formData.get("email");
1923
const password = formData.get("password");
@@ -58,7 +62,7 @@ export const action = async ({ request }: ActionArgs) => {
5862
});
5963
};
6064

61-
export const meta: V2_MetaFunction = () => [{ title: "Login" }];
65+
export const meta: MetaFunction = () => [{ title: "Login" }];
6266

6367
export default function LoginPage() {
6468
const [searchParams] = useSearchParams();

app/routes/logout.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type { ActionArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs } from "@remix-run/node";
22
import { redirect } from "@remix-run/node";
33

44
import { logout } from "~/session.server";
55

6-
export const action = async ({ request }: ActionArgs) => logout(request);
6+
export const action = async ({ request }: ActionFunctionArgs) =>
7+
logout(request);
78

89
export const loader = async () => redirect("/");

app/routes/notes.$noteId.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
22
import { json, redirect } from "@remix-run/node";
33
import {
44
Form,
@@ -11,7 +11,7 @@ import invariant from "tiny-invariant";
1111
import { deleteNote, getNote } from "~/models/note.server";
1212
import { requireUserId } from "~/session.server";
1313

14-
export const loader = async ({ params, request }: LoaderArgs) => {
14+
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
1515
const userId = await requireUserId(request);
1616
invariant(params.noteId, "noteId not found");
1717

@@ -22,7 +22,7 @@ export const loader = async ({ params, request }: LoaderArgs) => {
2222
return json({ note });
2323
};
2424

25-
export const action = async ({ params, request }: ActionArgs) => {
25+
export const action = async ({ params, request }: ActionFunctionArgs) => {
2626
const userId = await requireUserId(request);
2727
invariant(params.noteId, "noteId not found");
2828

app/routes/notes.new.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { ActionArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs } from "@remix-run/node";
22
import { json, redirect } from "@remix-run/node";
33
import { Form, useActionData } from "@remix-run/react";
44
import { useEffect, useRef } from "react";
55

66
import { createNote } from "~/models/note.server";
77
import { requireUserId } from "~/session.server";
88

9-
export const action = async ({ request }: ActionArgs) => {
9+
export const action = async ({ request }: ActionFunctionArgs) => {
1010
const userId = await requireUserId(request);
1111

1212
const formData = await request.formData();

app/routes/notes.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { LoaderArgs } from "@remix-run/node";
1+
import type { LoaderFunctionArgs } from "@remix-run/node";
22
import { json } from "@remix-run/node";
33
import { Form, Link, NavLink, Outlet, useLoaderData } from "@remix-run/react";
44

55
import { getNoteListItems } from "~/models/note.server";
66
import { requireUserId } from "~/session.server";
77
import { useUser } from "~/utils";
88

9-
export const loader = async ({ request }: LoaderArgs) => {
9+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1010
const userId = await requireUserId(request);
1111
const noteListItems = await getNoteListItems({ userId });
1212
return json({ noteListItems });

cypress/support/test-routes/create-user.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { ActionArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs } from "@remix-run/node";
22
import { redirect } from "@remix-run/node";
33

44
import { createUser } from "~/models/user.server";
55
import { createUserSession } from "~/session.server";
66

7-
export const action = async ({ request }: ActionArgs) => {
7+
export const action = async ({ request }: ActionFunctionArgs) => {
88
if (process.env.NODE_ENV === "production") {
99
console.error(
1010
"🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 test routes should not be enabled in production 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨",

cypress/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"types": ["node", "cypress", "@testing-library/cypress"],
1616
"esModuleInterop": true,
1717
"jsx": "react-jsx",
18-
"moduleResolution": "node",
19-
"target": "es2019",
18+
"moduleResolution": "Bundler",
19+
"target": "ES2020",
2020
"strict": true,
2121
"skipLibCheck": true,
2222
"resolveJsonModule": true,

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
"@architect/architect": "^10.14.0",
2626
"@architect/functions": "^7.0.0",
2727
"@paralleldrive/cuid2": "^2.2.2",
28-
"@remix-run/architect": "*",
29-
"@remix-run/css-bundle": "*",
30-
"@remix-run/node": "*",
31-
"@remix-run/react": "*",
32-
"@remix-run/server-runtime": "*",
28+
"@remix-run/architect": "^2.0.0-pre.8",
29+
"@remix-run/css-bundle": "^2.0.0-pre.8",
30+
"@remix-run/node": "^2.0.0-pre.8",
31+
"@remix-run/react": "^2.0.0-pre.8",
3332
"bcryptjs": "2.4.3",
3433
"isbot": "^3.6.13",
3534
"react": "^18.2.0",
@@ -38,8 +37,8 @@
3837
},
3938
"devDependencies": {
4039
"@faker-js/faker": "^8.0.2",
41-
"@remix-run/dev": "*",
42-
"@remix-run/eslint-config": "*",
40+
"@remix-run/dev": "^2.0.0-pre.8",
41+
"@remix-run/eslint-config": "^2.0.0-pre.8",
4342
"@testing-library/cypress": "^9.0.0",
4443
"@testing-library/jest-dom": "^5.17.0",
4544
"@types/architect__functions": "^3.13.7",
@@ -75,6 +74,6 @@
7574
"vitest": "^0.34.2"
7675
},
7776
"engines": {
78-
"node": ">=14"
77+
"node": ">=18.0.0"
7978
}
8079
}

remix.config.js

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
const path = require("path");
1+
const path = require("node:path");
22

33
/** @type {import('@remix-run/dev').AppConfig} */
44
module.exports = {
55
cacheDirectory: "./node_modules/.cache/remix",
6-
future: {
7-
v2_dev: true,
8-
v2_errorBoundary: true,
9-
v2_headers: true,
10-
v2_meta: true,
11-
v2_normalizeFormMethod: true,
12-
v2_routeConvention: true,
13-
},
146
ignoredRouteFiles: ["**/.*", "**/*.test.{js,jsx,ts,tsx}"],
157
publicPath: "/_static/build/",
16-
postcss: true,
178
server: "./server.ts",
189
serverBuildPath: "server/index.js",
1910
serverModuleFormat: "cjs",
20-
tailwind: true,
2111
routes(defineRoutes) {
2212
return defineRoutes((route) => {
2313
if (process.env.NODE_ENV === "production") return;

0 commit comments

Comments
 (0)