Skip to content

Commit a105445

Browse files
authored
Remove hashes on built filenames (#13567)
1 parent 5d6f801 commit a105445

File tree

15 files changed

+93
-87
lines changed

15 files changed

+93
-87
lines changed

.changeset/small-rocks-grab.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Remove hashes from files in `dist/` for easier usage with `patch-package`

integration/prefetch-test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ test.describe("prefetch", () => {
172172
await page.waitForSelector(
173173
// Look for either Rollup or Rolldown chunks
174174
[
175-
"link[rel='modulepreload'][href^='/assets/chunk-']",
175+
"link[rel='modulepreload'][href^='/assets/index-']",
176176
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
177177
].join(","),
178178
{ state: "attached" }
@@ -232,7 +232,7 @@ test.describe("prefetch", () => {
232232
await page.waitForSelector(
233233
// Look for either Rollup or Rolldown chunks
234234
[
235-
"link[rel='modulepreload'][href^='/assets/chunk-']",
235+
"link[rel='modulepreload'][href^='/assets/index-']",
236236
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
237237
].join(","),
238238
{ state: "attached" }
@@ -251,7 +251,7 @@ test.describe("prefetch", () => {
251251
await page.waitForSelector(
252252
// Look for either Rollup or Rolldown chunks
253253
[
254-
"link[rel='modulepreload'][href^='/assets/chunk-']",
254+
"link[rel='modulepreload'][href^='/assets/index-']",
255255
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
256256
].join(","),
257257
{ state: "attached" }
@@ -341,7 +341,7 @@ test.describe("prefetch", () => {
341341
await page.waitForSelector(
342342
// Look for either Rollup or Rolldown chunks
343343
[
344-
"link[rel='modulepreload'][href^='/assets/chunk-']",
344+
"link[rel='modulepreload'][href^='/assets/index-']",
345345
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
346346
].join(","),
347347
{ state: "attached" }
@@ -360,7 +360,7 @@ test.describe("prefetch", () => {
360360
await page.waitForSelector(
361361
// Look for either Rollup or Rolldown chunks
362362
[
363-
"link[rel='modulepreload'][href^='/assets/chunk-']",
363+
"link[rel='modulepreload'][href^='/assets/index-']",
364364
"link[rel='modulepreload'][href^='/assets/jsx-runtime-']",
365365
].join(","),
366366
{ state: "attached" }

packages/react-router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export type {
277277
MiddlewareEnabled as UNSAFE_MiddlewareEnabled,
278278
} from "./lib/types/future.ts";
279279
export type { unstable_SerializesTo } from "./lib/types/serializes-to.ts";
280-
export type { Register } from "./lib/types/register";
280+
export type { Register, Pages, RouteFiles } from "./lib/types/register";
281281
export { href } from "./lib/href";
282282

283283
///////////////////////////////////////////////////////////////////////////////
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { RouteFiles } from "react-router";
2+
import type {
3+
GetLoaderData,
4+
GetActionData,
5+
} from "./lib/types/internal-export/route-data";
6+
import type { RouteModule } from "./lib/types/internal-export/route-module";
7+
import type { Params } from "./lib/types/internal-export/params";
8+
9+
export type { GetAnnotations } from "./lib/types/internal-export/route-module-annotations";
10+
11+
export type GetInfo<T extends { file: keyof RouteFiles; module: RouteModule }> =
12+
{
13+
params: Params<T["file"]>;
14+
loaderData: GetLoaderData<T["module"]>;
15+
actionData: GetActionData<T["module"]>;
16+
};

packages/react-router/lib/dom/lib.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import {
9494
useResolvedPath,
9595
useRouteId,
9696
} from "../hooks";
97-
import type { SerializeFrom } from "../types/route-data";
97+
import type { SerializeFrom } from "../types/internal-export/route-data";
9898

9999
////////////////////////////////////////////////////////////////////////////////
100100
//#region Global Stuff

packages/react-router/lib/dom/ssr/routeModules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {
1313
import type { EntryRoute } from "./routes";
1414
import type { DataRouteMatch } from "../../context";
1515
import type { LinkDescriptor } from "../../router/links";
16-
import type { SerializeFrom } from "../../types/route-data";
16+
import type { SerializeFrom } from "../../types/internal-export/route-data";
1717

1818
export interface RouteModules {
1919
[routeId: string]: RouteModule | undefined;

packages/react-router/lib/hooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import {
5050
resolveTo,
5151
stripBasename,
5252
} from "./router/utils";
53-
import type { SerializeFrom } from "./types/route-data";
53+
import type { SerializeFrom } from "./types/internal-export/route-data";
5454

5555
/**
5656
Resolves a URL against the current location.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Import this from the react-router public API to avoid duplicates in dist/
2+
import type { Pages, RouteFiles } from "react-router";
3+
import type { Normalize } from "../utils";
4+
5+
export type Params<RouteFile extends keyof RouteFiles> = Normalize<
6+
Pages[RouteFiles[RouteFile]["page"]]["params"]
7+
>;

packages/react-router/lib/types/route-data.ts renamed to packages/react-router/lib/types/internal-export/route-data.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type {
22
ClientLoaderFunctionArgs,
33
ClientActionFunctionArgs,
4-
} from "../dom/ssr/routeModules";
5-
import type { DataWithResponseInit } from "../router/utils";
6-
import type { Serializable } from "../server-runtime/single-fetch";
4+
} from "../../dom/ssr/routeModules";
5+
import type { DataWithResponseInit } from "../../router/utils";
6+
import type { Serializable } from "../../server-runtime/single-fetch";
7+
import type { unstable_SerializesTo } from "../serializes-to";
8+
import type { Equal, Expect, Func, IsAny, Pretty } from "../utils";
79
import type { RouteModule } from "./route-module";
8-
import type { unstable_SerializesTo } from "./serializes-to";
9-
import type { Equal, Expect, Func, IsAny, Pretty } from "./utils";
1010

1111
// prettier-ignore
1212
type Serialize<T> =

packages/react-router/lib/types/route-module-annotations.ts renamed to packages/react-router/lib/types/internal-export/route-module-annotations.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import type { MetaDescriptor } from "../dom/ssr/routeModules";
2-
import type { Location } from "../router/history";
3-
import type { LinkDescriptor } from "../router/links";
1+
import type { MetaDescriptor } from "../../dom/ssr/routeModules";
2+
import type { Location } from "../../router/history";
3+
import type { LinkDescriptor } from "../../router/links";
44
import type {
55
unstable_MiddlewareNextFunction,
66
unstable_RouterContextProvider,
7-
} from "../router/utils";
8-
import type { AppLoadContext } from "../server-runtime/data";
9-
import type { MiddlewareEnabled } from "./future";
10-
7+
} from "../../router/utils";
8+
import type { AppLoadContext } from "../../server-runtime/data";
9+
import type { MiddlewareEnabled } from "../future";
10+
import type { Pretty } from "../utils";
1111
import type { GetLoaderData, ServerDataFrom } from "./route-data";
1212
import type { RouteModule } from "./route-module";
13-
import type { Pretty } from "./utils";
1413

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

packages/react-router/lib/types/route-module.ts renamed to packages/react-router/lib/types/internal-export/route-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Func } from "./utils";
1+
import type { Func } from "../utils";
22

33
export type RouteModule = {
44
meta?: Func;

packages/react-router/lib/types/internal.ts

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

packages/react-router/lib/types/params.ts

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

packages/react-router/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
},
4040
"./internal": {
4141
"node": {
42-
"types": "./dist/development/lib/types/internal.d.ts"
42+
"types": "./dist/development/internal-export.d.ts"
4343
},
4444
"import": {
45-
"types": "./dist/development/lib/types/internal.d.mts"
45+
"types": "./dist/development/internal-export.d.mts"
4646
},
4747
"default": {
48-
"types": "./dist/development/lib/types/index.d.ts"
48+
"types": "./dist/development/internal-export.d.ts"
4949
}
5050
},
5151
"./dom": {

packages/react-router/tsup.config.ts

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
1-
import { defineConfig } from "tsup";
1+
import { type Options, defineConfig } from "tsup";
22

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

66
import pkg from "./package.json";
77

8-
const entry = ["index.ts", "dom-export.ts", "lib/types/internal.ts"];
9-
10-
const config = (enableDevWarnings: boolean) =>
11-
defineConfig([
12-
{
13-
clean: false,
14-
entry,
15-
format: ["cjs"],
16-
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
17-
external: ["react-router"],
18-
outDir: enableDevWarnings ? "dist/development" : "dist/production",
19-
dts: true,
20-
banner: {
21-
js: createBanner(pkg.name, pkg.version),
22-
},
23-
define: {
24-
"import.meta.hot": "undefined",
25-
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
26-
__DEV__: JSON.stringify(enableDevWarnings),
27-
},
8+
const config = (entry: string, enableDevWarnings: boolean): Options[] => [
9+
{
10+
clean: false,
11+
entry: [entry],
12+
format: ["cjs"],
13+
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
14+
external: ["react-router"],
15+
outDir: enableDevWarnings ? "dist/development" : "dist/production",
16+
dts: true,
17+
banner: {
18+
js: createBanner(pkg.name, pkg.version),
19+
},
20+
define: {
21+
"import.meta.hot": "undefined",
22+
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
23+
__DEV__: JSON.stringify(enableDevWarnings),
24+
},
25+
},
26+
{
27+
clean: false,
28+
entry: [entry],
29+
format: ["esm"],
30+
// Don't bundle `react-router` in sub-exports (i.e., `react-router/dom`)
31+
external: ["react-router"],
32+
outDir: enableDevWarnings ? "dist/development" : "dist/production",
33+
dts: true,
34+
banner: {
35+
js: createBanner(pkg.name, pkg.version),
2836
},
29-
{
30-
clean: false,
31-
entry,
32-
format: ["esm"],
33-
// We don't do the external thing for `react-router` here because it
34-
// doesn't get bundled by default in the ESM build, and when we tried it
35-
// in https://github.com/remix-run/react-router/pull/13497 it changed up
36-
// some chunk creation that we didn't want to risk having any side effects
37-
outDir: enableDevWarnings ? "dist/development" : "dist/production",
38-
dts: true,
39-
banner: {
40-
js: createBanner(pkg.name, pkg.version),
41-
},
42-
define: {
43-
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
44-
__DEV__: JSON.stringify(enableDevWarnings),
45-
},
37+
define: {
38+
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
39+
__DEV__: JSON.stringify(enableDevWarnings),
4640
},
47-
]);
41+
},
42+
];
4843

4944
export default defineConfig([
50-
// @ts-expect-error
51-
...config(false),
52-
...config(true),
45+
...config("index.ts", false),
46+
...config("index.ts", true),
47+
...config("dom-export.ts", false),
48+
...config("dom-export.ts", true),
49+
...config("internal-export.ts", false),
50+
...config("internal-export.ts", true),
5351
]);

0 commit comments

Comments
 (0)