Skip to content

Commit 559b0eb

Browse files
Move server-runtime into react-router (#11698)
* Move server-runtime into react-router * Clean up comments * Remove unused index * Update changeset * Fix test imports * Set test env to jsdom * Clean redundant diffs * Fix EntryContext type errors * Remove stray comment * Fix tests in Node 18 * Lower filesize limit * Remove server-runtime reexport modules
1 parent 97be8ab commit 559b0eb

File tree

96 files changed

+315
-1805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+315
-1805
lines changed

.changeset/collapse-packages.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44

55
- Collapse `@remix-run/router` into `react-router`
66
- Collapse `react-router-dom` into `react-router`
7+
- Collapse `@remix-run/server-runtime` into `react-router`
78
- Collapse `@remix-run/testing` into `react-router`

.changeset/config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"@react-router/dev",
1313
"@react-router/express",
1414
"@react-router/node",
15-
"@react-router/serve",
16-
"@react-router/server-runtime"
15+
"@react-router/serve"
1716
]
1817
],
1918
"linked": [],

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ This repository is a monorepo containing the following packages:
2525
- [`@react-router/express`](/packages/remix-express)
2626
- [`@react-router/node`](/packages/remix-node)
2727
- [`@react-router/serve`](/packages/remix-serve)
28-
- [`@react-router/server-runtime`](/packages/remix-server-runtime)
2928
- [`react-router`](/packages/react-router)
3029
- [`react-router-dom`](/packages/react-router-dom)
3130

integration/client-data-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@playwright/test";
22

3-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
3+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
44
import {
55
createAppFixture,
66
createFixture,

integration/error-boundary-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@playwright/test";
22

3-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
3+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
44
import {
55
createAppFixture,
66
createFixture,

integration/error-boundary-v2-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Page } from "@playwright/test";
22
import { test, expect } from "@playwright/test";
33

4-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
4+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
55
import {
66
createAppFixture,
77
createFixture,

integration/error-data-request-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test.describe("ErrorBoundary", () => {
5858
`,
5959

6060
[`app/routes/loader-return-json.jsx`]: js`
61-
import { json } from "@react-router/server-runtime";
61+
import { json } from "react-router";
6262
6363
export async function loader() {
6464
return json({ ok: true });
@@ -80,7 +80,7 @@ test.describe("ErrorBoundary", () => {
8080
`,
8181

8282
[`app/routes/action-return-json.jsx`]: js`
83-
import { json } from "@react-router/server-runtime";
83+
import { json } from "react-router";
8484
8585
export async function action() {
8686
return json({ ok: true });

integration/error-sanitization-test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { test, expect } from "@playwright/test";
2-
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "react-router";
2+
import {
3+
UNSAFE_ErrorResponseImpl as ErrorResponseImpl,
4+
UNSAFE_ServerMode as ServerMode,
5+
} from "react-router";
36

4-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
57
import type { Fixture } from "./helpers/create-fixture.js";
68
import {
79
createAppFixture,
@@ -77,8 +79,7 @@ const routeFiles = {
7779

7880
"app/routes/defer.tsx": js`
7981
import * as React from 'react';
80-
import { defer } from "@react-router/server-runtime";
81-
import { Await, useAsyncError, useLoaderData, useRouteError } from "react-router";
82+
import { defer, Await, useAsyncError, useLoaderData, useRouteError } from "react-router";
8283
8384
export function loader({ request }) {
8485
if (new URL(request.url).searchParams.has('loader')) {

integration/form-test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ test.describe("Forms", () => {
394394
`,
395395

396396
"app/routes/empty-file-upload.tsx": js`
397-
import { json } from "@react-router/server-runtime";
398-
import { Form, useActionData } from "react-router";
397+
import { json, Form, useActionData } from "react-router";
399398
400399
export async function action({ request }) {
401400
let formData = await request.formData();
@@ -454,8 +453,7 @@ test.describe("Forms", () => {
454453
"myfile.txt": "stuff",
455454

456455
"app/routes/pathless-layout-parent.tsx": js`
457-
import { json } from '@react-router/server-runtime'
458-
import { Form, Outlet, useActionData } from "react-router"
456+
import { json, Form, Outlet, useActionData } from "react-router"
459457
460458
export async function action({ request }) {
461459
return json({ submitted: true });

integration/headers-test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@playwright/test";
22

3-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
3+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
44
import { createFixture, js } from "./helpers/create-fixture.js";
55
import type { Fixture } from "./helpers/create-fixture.js";
66

@@ -159,8 +159,7 @@ test.describe.skip("headers export", () => {
159159
`,
160160

161161
"app/routes/cookie.tsx": js`
162-
import { json } from "@react-router/server-runtime";
163-
import { Outlet } from "react-router";
162+
import { json, Outlet } from "react-router";
164163
165164
export function loader({ request }) {
166165
if (new URL(request.url).searchParams.has("parent-throw")) {

integration/helpers/create-fixture.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import stripIndent from "strip-indent";
88
import { sync as spawnSync, spawn } from "cross-spawn";
99
import type { JsonObject } from "type-fest";
1010

11-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
12-
import type { ServerBuild } from "@react-router/server-runtime";
13-
import { createRequestHandler } from "@react-router/server-runtime";
11+
import {
12+
type ServerBuild,
13+
createRequestHandler,
14+
UNSAFE_ServerMode as ServerMode,
15+
UNSAFE_decodeViaTurboStream as decodeViaTurboStream,
16+
} from "react-router";
1417
import { createRequestHandler as createExpressHandler } from "@react-router/express";
1518
import { installGlobals } from "@react-router/node";
16-
import { UNSAFE_decodeViaTurboStream as decodeViaTurboStream } from "react-router";
1719

1820
import { viteConfig } from "./vite.js";
1921

integration/helpers/node-template/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"@react-router/express": "workspace:*",
1515
"@react-router/node": "workspace:*",
1616
"@react-router/serve": "workspace:*",
17-
"@react-router/server-runtime": "workspace:*",
1817
"express": "^4.17.1",
1918
"isbot": "^4.1.0",
2019
"react": "^18.2.0",

integration/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"@react-router/dev": "workspace:*",
1313
"@react-router/express": "workspace:*",
1414
"@react-router/node": "workspace:*",
15-
"@react-router/server-runtime": "workspace:*",
1615
"@types/express": "^4.17.9",
1716
"@vanilla-extract/css": "^1.10.0",
1817
"@vanilla-extract/vite-plugin": "^3.9.2",

integration/resource-routes-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@playwright/test";
22

3-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
3+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
44
import {
55
createAppFixture,
66
createFixture,

integration/root-route-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@playwright/test";
22

3-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
3+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
44
import {
55
createAppFixture,
66
createFixture,

integration/single-fetch-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
js,
77
} from "./helpers/create-fixture.js";
88
import { PlaywrightFixture } from "./helpers/playwright-fixture.js";
9-
import { UNSAFE_ServerMode as ServerMode } from "@react-router/server-runtime";
9+
import { UNSAFE_ServerMode as ServerMode } from "react-router";
1010

1111
const ISO_DATE = "2024-03-12T12:00:00.000Z";
1212

jest/jest.config.shared.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module.exports = {
1313
"@react-router/express$": "<rootDir>/../remix-express/index.ts",
1414
"@react-router/node$": "<rootDir>/../remix-node/index.ts",
1515
"@react-router/serve$": "<rootDir>/../remix-serve/index.ts",
16-
"@react-router/server-runtime$":
17-
"<rootDir>/../remix-server-runtime/index.ts",
1816
"^react-router$": "<rootDir>/../react-router/index.ts",
1917
"^@web3-storage/multipart-parser$": require.resolve(
2018
"@web3-storage/multipart-parser"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@
131131
},
132132
"filesize": {
133133
"packages/react-router/dist/react-router.production.min.js": {
134-
"none": "120 kB"
134+
"none": "124 kB"
135135
},
136136
"packages/react-router/dist/umd/react-router.production.min.js": {
137-
"none": "125 kB"
137+
"none": "130 kB"
138138
}
139139
},
140140
"pnpm": {

packages/react-router/.eslintrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/remix-server-runtime/.eslintrc.js renamed to packages/react-router/.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
let restrictedGlobalsError = `Node globals are not allowed in this package.`;
22

33
module.exports = {
4-
extends: "../../.eslintrc",
4+
env: {
5+
browser: true,
6+
commonjs: true,
7+
},
58
rules: {
9+
strict: 0,
10+
"no-restricted-syntax": ["error", "LogicalExpression[operator='??']"],
611
"no-restricted-globals": [
712
"error",
813
{ name: "__dirname", message: restrictedGlobalsError },

packages/react-router/__tests__/.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"jest": true
44
},
55
"rules": {
6-
"no-console": 0
6+
"no-console": 0,
7+
"no-restricted-globals": "off",
8+
"import/no-nodejs-modules": "off"
79
}
810
}

packages/react-router/__tests__/router/data-strategy-test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { DataStrategyFunction, DataStrategyMatch } from "../../lib/router";
1+
import type {
2+
unstable_DataStrategyFunction as DataStrategyFunction,
3+
unstable_DataStrategyMatch as DataStrategyMatch,
4+
} from "../../lib/router";
25
import { json } from "../../lib/router";
36
import { createDeferred, setup } from "./utils/data-router-setup";
47
import { createFormData, tick } from "./utils/utils";

packages/remix-server-runtime/__tests__/cookies-test.ts renamed to packages/react-router/__tests__/server-runtime/cookies-test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { createCookieFactory, isCookie } from "../cookies";
2-
import type { SignFunction, UnsignFunction } from "../crypto";
1+
import {
2+
createCookieFactory,
3+
isCookie,
4+
} from "../../lib/server-runtime/cookies";
5+
import type {
6+
SignFunction,
7+
UnsignFunction,
8+
} from "../../lib/server-runtime/crypto";
39

410
const sign: SignFunction = async (value, secret) => {
511
return JSON.stringify({ value, secret });

packages/remix-server-runtime/__tests__/data-test.ts renamed to packages/react-router/__tests__/server-runtime/data-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UNSAFE_decodeViaTurboStream as decodeViaTurboStream } from "react-router";
22

3-
import type { ServerBuild } from "../build";
4-
import { createRequestHandler } from "../server";
3+
import type { ServerBuild } from "../../lib/server-runtime/build";
4+
import { createRequestHandler } from "../../lib/server-runtime/server";
55

66
describe("loaders", () => {
77
// so that HTML/Fetch requests are the same, and so redirects don't hang on to

packages/remix-server-runtime/__tests__/formData-test.ts renamed to packages/react-router/__tests__/server-runtime/formData-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { parseMultipartFormData } from "../formData";
1+
/**
2+
* @jest-environment node
3+
*/
4+
5+
import { parseMultipartFormData } from "../../lib/server-runtime/formData";
26

37
declare global {
48
interface RequestInit {

packages/remix-server-runtime/__tests__/handle-error-test.ts renamed to packages/react-router/__tests__/server-runtime/handle-error-test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "react-router";
22

3-
import type { ServerBuild } from "../build";
4-
import { createRequestHandler } from "../server";
5-
import { json } from "../responses";
3+
import type { ServerBuild } from "../../lib/server-runtime/build";
4+
import { createRequestHandler } from "../../lib/server-runtime/server";
5+
import { json } from "../../lib/server-runtime/responses";
66

77
function getHandler(routeModule = {}, entryServerModule = {}) {
88
let routeId = "root";

packages/remix-server-runtime/__tests__/handler-test.ts renamed to packages/react-router/__tests__/server-runtime/handler-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { json } from "../responses";
2-
import { createRequestHandler } from "../server";
1+
import { json } from "../../lib/server-runtime/responses";
2+
import { createRequestHandler } from "../../lib/server-runtime/server";
33

44
describe("createRequestHandler", () => {
55
it("retains request headers when stripping body off for loaders", async () => {

packages/remix-server-runtime/__tests__/markup-test.ts renamed to packages/react-router/__tests__/server-runtime/markup-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import vm from "vm";
22

3-
import { escapeHtml } from "../markup";
3+
import { escapeHtml } from "../../lib/server-runtime/markup";
44

55
describe("escapeHtml", () => {
66
// These tests are based on https://github.com/zertosh/htmlescape/blob/3e6cf0614dd0f778fd0131e69070b77282150c15/test/htmlescape-test.js

packages/remix-server-runtime/__tests__/responses-test.ts renamed to packages/react-router/__tests__/server-runtime/responses-test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import type { TypedResponse } from "../index";
2-
import { json, redirect } from "../index";
1+
/**
2+
* @jest-environment node
3+
*/
4+
5+
import type { TypedResponse } from "../../lib/server-runtime/responses";
6+
import { json, redirect } from "../../lib/server-runtime/responses";
37
import { isEqual } from "./utils";
48

59
describe("json", () => {

packages/remix-server-runtime/__tests__/server-test.ts renamed to packages/react-router/__tests__/server-runtime/server-test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
/**
2+
* @jest-environment node
3+
*/
4+
15
import type { StaticHandlerContext } from "react-router";
26
import { json } from "react-router";
37

4-
import { createRequestHandler } from "..";
5-
import { ServerMode } from "../mode";
6-
import type { ServerBuild } from "../build";
8+
import { createRequestHandler } from "../../lib/server-runtime/server";
9+
import { ServerMode } from "../../lib/server-runtime/mode";
10+
import type { ServerBuild } from "../../lib/server-runtime/build";
711
import { mockServerBuild } from "./utils";
812

913
function spyConsole() {

packages/remix-server-runtime/__tests__/sessions-test.ts renamed to packages/react-router/__tests__/server-runtime/sessions-test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { createCookieFactory } from "../cookies";
2-
import type { SignFunction, UnsignFunction } from "../crypto";
1+
import { createCookieFactory } from "../../lib/server-runtime/cookies";
2+
import type {
3+
SignFunction,
4+
UnsignFunction,
5+
} from "../../lib/server-runtime/crypto";
36
import {
47
createSession,
58
createSessionStorageFactory,
69
isSession,
7-
} from "../sessions";
8-
import { createCookieSessionStorageFactory } from "../sessions/cookieStorage";
9-
import { createMemorySessionStorageFactory } from "../sessions/memoryStorage";
10+
} from "../../lib/server-runtime/sessions";
11+
import { createCookieSessionStorageFactory } from "../../lib/server-runtime/sessions/cookieStorage";
12+
import { createMemorySessionStorageFactory } from "../../lib/server-runtime/sessions/memoryStorage";
1013

1114
function getCookieFromSetCookie(setCookie: string): string {
1215
return setCookie.split(/;\s*/)[0];

packages/remix-server-runtime/__tests__/utils.ts renamed to packages/react-router/__tests__/server-runtime/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import type {
55
HandleErrorFunction,
66
HeadersFunction,
77
LoaderFunction,
8-
} from "../";
9-
import type { FutureConfig } from "../entry";
10-
import type { EntryRoute, ServerRoute, ServerRouteManifest } from "../routes";
8+
} from "../../lib/server-runtime";
9+
import type { FutureConfig } from "../../lib/server-runtime/entry";
10+
import type {
11+
EntryRoute,
12+
ServerRoute,
13+
ServerRouteManifest,
14+
} from "../../lib/server-runtime/routes";
1115

1216
export function mockServerBuild(
1317
routes: Record<

packages/react-router/__tests__/setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ if (!globalThis.TransformStream) {
4040
const { TransformStream } = require("node:stream/web");
4141
globalThis.TransformStream = TransformStream;
4242
}
43+
44+
if (!globalThis.File) {
45+
const { File } = require("undici");
46+
globalThis.File = File;
47+
}

0 commit comments

Comments
 (0)