Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/many-bees-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

[REMOVE] Revert tsup changes
5 changes: 0 additions & 5 deletions .changeset/small-rocks-grab.md

This file was deleted.

1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ Date: 2025-05-21

### Patch Changes

- `react-router` - Remove hashes from files in `dist/` for easier usage with `patch-package` ([#13567](https://github.com/remix-run/react-router/pull/13567))
- `react-router` - Partially revert optimization added in `7.1.4` to reduce calls to `matchRoutes` because it surfaced other issues ([#13562](https://github.com/remix-run/react-router/pull/13562))
- `react-router` - Update `Route.MetaArgs` to reflect that `data` can be potentially `undefined` ([#13563](https://github.com/remix-run/react-router/pull/13563))
- This is primarily for cases where a route `loader` threw an error to it's own `ErrorBoundary`, but it also arises in the case of a 404 which renders the root `ErrorBoundary`/`meta` but the root `loader` did not run because not routes matched
Expand Down
10 changes: 5 additions & 5 deletions integration/prefetch-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ test.describe("prefetch", () => {
await page.waitForSelector(
// Look for either Rollup or Rolldown chunks
[
"link[rel='modulepreload'][href^='/assets/index-']",
"link[rel='modulepreload'][href^='/assets/chunk-']",
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
].join(","),
{ state: "attached" }
Expand Down Expand Up @@ -232,7 +232,7 @@ test.describe("prefetch", () => {
await page.waitForSelector(
// Look for either Rollup or Rolldown chunks
[
"link[rel='modulepreload'][href^='/assets/index-']",
"link[rel='modulepreload'][href^='/assets/chunk-']",
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
].join(","),
{ state: "attached" }
Expand All @@ -251,7 +251,7 @@ test.describe("prefetch", () => {
await page.waitForSelector(
// Look for either Rollup or Rolldown chunks
[
"link[rel='modulepreload'][href^='/assets/index-']",
"link[rel='modulepreload'][href^='/assets/chunk-']",
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
].join(","),
{ state: "attached" }
Expand Down Expand Up @@ -341,7 +341,7 @@ test.describe("prefetch", () => {
await page.waitForSelector(
// Look for either Rollup or Rolldown chunks
[
"link[rel='modulepreload'][href^='/assets/index-']",
"link[rel='modulepreload'][href^='/assets/chunk-']",
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
].join(","),
{ state: "attached" }
Expand All @@ -360,7 +360,7 @@ test.describe("prefetch", () => {
await page.waitForSelector(
// Look for either Rollup or Rolldown chunks
[
"link[rel='modulepreload'][href^='/assets/index-']",
"link[rel='modulepreload'][href^='/assets/chunk-']",
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
].join(","),
{ state: "attached" }
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export type {
MiddlewareEnabled as UNSAFE_MiddlewareEnabled,
} from "./lib/types/future.ts";
export type { unstable_SerializesTo } from "./lib/types/serializes-to.ts";
export type { Register, Pages, RouteFiles } from "./lib/types/register";
export type { Register } from "./lib/types/register";
export { href } from "./lib/href";

///////////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 0 additions & 16 deletions packages/react-router/internal-export.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react-router/lib/dom/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import {
useResolvedPath,
useRouteId,
} from "../hooks";
import type { SerializeFrom } from "../types/internal-export/route-data";
import type { SerializeFrom } from "../types/route-data";

////////////////////////////////////////////////////////////////////////////////
//#region Global Stuff
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/lib/dom/ssr/routeModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
import type { EntryRoute } from "./routes";
import type { DataRouteMatch } from "../../context";
import type { LinkDescriptor } from "../../router/links";
import type { SerializeFrom } from "../../types/internal-export/route-data";
import type { SerializeFrom } from "../../types/route-data";

export interface RouteModules {
[routeId: string]: RouteModule | undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
resolveTo,
stripBasename,
} from "./router/utils";
import type { SerializeFrom } from "./types/internal-export/route-data";
import type { SerializeFrom } from "./types/route-data";

/**
Resolves a URL against the current location.
Expand Down
7 changes: 0 additions & 7 deletions packages/react-router/lib/types/internal-export/params.ts

This file was deleted.

13 changes: 13 additions & 0 deletions packages/react-router/lib/types/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type { GetAnnotations } from "./route-module-annotations";

import type { Params } from "./params";
import type { RouteFiles } from "./register";
import type { GetLoaderData, GetActionData } from "./route-data";
import type { RouteModule } from "./route-module.ts";

export type GetInfo<T extends { file: keyof RouteFiles; module: RouteModule }> =
{
params: Params<T["file"]>;
loaderData: GetLoaderData<T["module"]>;
actionData: GetActionData<T["module"]>;
};
6 changes: 6 additions & 0 deletions packages/react-router/lib/types/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Pages, RouteFiles } from "./register";
import type { Normalize } from "./utils";

export type Params<RouteFile extends keyof RouteFiles> = Normalize<
Pages[RouteFiles[RouteFile]["page"]]["params"]
>;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type {
ClientLoaderFunctionArgs,
ClientActionFunctionArgs,
} from "../../dom/ssr/routeModules";
import type { DataWithResponseInit } from "../../router/utils";
import type { Serializable } from "../../server-runtime/single-fetch";
import type { unstable_SerializesTo } from "../serializes-to";
import type { Equal, Expect, Func, IsAny, Pretty } from "../utils";
} from "../dom/ssr/routeModules";
import type { DataWithResponseInit } from "../router/utils";
import type { Serializable } from "../server-runtime/single-fetch";
import type { RouteModule } from "./route-module";
import type { unstable_SerializesTo } from "./serializes-to";
import type { Equal, Expect, Func, IsAny, Pretty } from "./utils";

// prettier-ignore
type Serialize<T> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { MetaDescriptor } from "../../dom/ssr/routeModules";
import type { Location } from "../../router/history";
import type { LinkDescriptor } from "../../router/links";
import type { MetaDescriptor } from "../dom/ssr/routeModules";
import type { Location } from "../router/history";
import type { LinkDescriptor } from "../router/links";
import type {
unstable_MiddlewareNextFunction,
unstable_RouterContextProvider,
} from "../../router/utils";
import type { AppLoadContext } from "../../server-runtime/data";
import type { MiddlewareEnabled } from "../future";
import type { Pretty } from "../utils";
} from "../router/utils";
import type { AppLoadContext } from "../server-runtime/data";
import type { MiddlewareEnabled } from "./future";

import type { GetLoaderData, ServerDataFrom } from "./route-data";
import type { RouteModule } from "./route-module";
import type { Pretty } from "./utils";

type MaybePromise<T> = T | Promise<T>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Func } from "../utils";
import type { Func } from "./utils";

export type RouteModule = {
meta?: Func;
Expand Down
6 changes: 3 additions & 3 deletions packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
},
"./internal": {
"node": {
"types": "./dist/development/internal-export.d.ts"
"types": "./dist/development/lib/types/internal.d.ts"
},
"import": {
"types": "./dist/development/internal-export.d.mts"
"types": "./dist/development/lib/types/internal.d.mts"
},
"default": {
"types": "./dist/development/internal-export.d.ts"
"types": "./dist/development/lib/types/index.d.ts"
}
},
"./dom": {
Expand Down
82 changes: 42 additions & 40 deletions packages/react-router/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
import { type Options, defineConfig } from "tsup";
import { defineConfig } from "tsup";

// @ts-ignore - out of scope
import { createBanner } from "../../build.utils.js";

import pkg from "./package.json";

const config = (entry: string, enableDevWarnings: boolean): Options[] => [
{
clean: false,
entry: [entry],
format: ["cjs"],
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
external: ["react-router"],
outDir: enableDevWarnings ? "dist/development" : "dist/production",
dts: true,
banner: {
js: createBanner(pkg.name, pkg.version),
},
define: {
"import.meta.hot": "undefined",
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
__DEV__: JSON.stringify(enableDevWarnings),
},
},
{
clean: false,
entry: [entry],
format: ["esm"],
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
external: ["react-router"],
outDir: enableDevWarnings ? "dist/development" : "dist/production",
dts: true,
banner: {
js: createBanner(pkg.name, pkg.version),
const entry = ["index.ts", "dom-export.ts", "lib/types/internal.ts"];

const config = (enableDevWarnings: boolean) =>
defineConfig([
{
clean: false,
entry,
format: ["cjs"],
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
external: ["react-router"],
outDir: enableDevWarnings ? "dist/development" : "dist/production",
dts: true,
banner: {
js: createBanner(pkg.name, pkg.version),
},
define: {
"import.meta.hot": "undefined",
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
__DEV__: JSON.stringify(enableDevWarnings),
},
},
define: {
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
__DEV__: JSON.stringify(enableDevWarnings),
{
clean: false,
entry,
format: ["esm"],
// We don't do the external thing for `react-router` here because it
// doesn't get bundled by default in the ESM build, and when we tried it
// in https://github.com/remix-run/react-router/pull/13497 it changed up
// some chunk creation that we didn't want to risk having any side effects
outDir: enableDevWarnings ? "dist/development" : "dist/production",
dts: true,
banner: {
js: createBanner(pkg.name, pkg.version),
},
define: {
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
__DEV__: JSON.stringify(enableDevWarnings),
},
},
},
];
]);

export default defineConfig([
...config("index.ts", false),
...config("index.ts", true),
...config("dom-export.ts", false),
...config("dom-export.ts", true),
...config("internal-export.ts", false),
...config("internal-export.ts", true),
// @ts-expect-error
...config(false),
...config(true),
]);