Skip to content

Commit e7dd361

Browse files
committed
Remove unused RSC exports and dead types from public API
1 parent 28b09ce commit e7dd361

7 files changed

Lines changed: 12 additions & 116 deletions

File tree

packages/react-router/src/client/index.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ export function wrapServerFunction<T extends (...args: any[]) => Promise<any>>(
3535
return serverFunction;
3636
}
3737

38-
/**
39-
* Just a passthrough in case this is imported from the client.
40-
*/
41-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
42-
export function wrapServerFunctions<T extends Record<string, (...args: any[]) => Promise<any>>>(
43-
_moduleName: string,
44-
serverFunctions: T,
45-
): T {
46-
return serverFunctions;
47-
}
48-
4938
/**
5039
* @deprecated ErrorBoundary is deprecated, use React Router's error boundary instead.
5140
* See https://docs.sentry.io/platforms/javascript/guides/react-router/#report-errors-from-error-boundaries

packages/react-router/src/index.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ export declare const unleashIntegration: typeof clientSdk.unleashIntegration;
3131

3232
export declare const wrapServerComponent: typeof serverSdk.wrapServerComponent;
3333
export declare const wrapServerFunction: typeof serverSdk.wrapServerFunction;
34-
export declare const wrapServerFunctions: typeof serverSdk.wrapServerFunctions;

packages/react-router/src/server/index.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@ export {
2020
} from './createServerInstrumentation';
2121

2222
// React Server Components (RSC) - React Router v7.9.0+
23-
export {
24-
wrapMatchRSCServerRequest,
25-
wrapRouteRSCServerRequest,
26-
wrapServerFunction,
27-
wrapServerFunctions,
28-
wrapServerComponent,
29-
isServerComponentContext,
30-
} from './rsc';
23+
export { wrapServerFunction, wrapServerComponent } from './rsc';
3124

32-
export type {
33-
RSCRouteConfigEntry,
34-
RSCPayload,
35-
RSCMatch,
36-
DecodedPayload,
37-
RouterContextProvider,
38-
MatchRSCServerRequestArgs,
39-
MatchRSCServerRequestFn,
40-
RouteRSCServerRequestArgs,
41-
RouteRSCServerRequestFn,
42-
RSCHydratedRouterProps,
43-
ServerComponentContext,
44-
WrapServerFunctionOptions,
45-
} from './rsc';
25+
export type { ServerComponentContext, WrapServerFunctionOptions } from './rsc';
Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
1-
export { wrapMatchRSCServerRequest } from './wrapMatchRSCServerRequest';
2-
export { wrapRouteRSCServerRequest } from './wrapRouteRSCServerRequest';
3-
export { wrapServerFunction, wrapServerFunctions } from './wrapServerFunction';
4-
export { wrapServerComponent, isServerComponentContext } from './wrapServerComponent';
1+
export { wrapServerFunction } from './wrapServerFunction';
2+
export { wrapServerComponent } from './wrapServerComponent';
53

6-
export type {
7-
RSCRouteConfigEntry,
8-
RSCPayload,
9-
RSCMatch,
10-
DecodedPayload,
11-
RouterContextProvider,
12-
DecodeReplyFunction,
13-
DecodeActionFunction,
14-
DecodeFormStateFunction,
15-
LoadServerActionFunction,
16-
SSRCreateFromReadableStreamFunction,
17-
BrowserCreateFromReadableStreamFunction,
18-
MatchRSCServerRequestArgs,
19-
MatchRSCServerRequestFn,
20-
RouteRSCServerRequestArgs,
21-
RouteRSCServerRequestFn,
22-
RSCHydratedRouterProps,
23-
ServerComponentContext,
24-
WrapServerFunctionOptions,
25-
} from './types';
4+
export type { ServerComponentContext, WrapServerFunctionOptions } from './types';

packages/react-router/src/server/rsc/types.ts

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
/**
2-
* Type definitions for React Router RSC (React Server Components) APIs.
3-
*
4-
* These types mirror the unstable RSC APIs from react-router v7.9.0+.
5-
* All RSC APIs in React Router are prefixed with `unstable_` and subject to change.
6-
*/
7-
8-
/**
9-
* RSC route configuration entry - mirrors `unstable_RSCRouteConfigEntry` from react-router.
10-
*/
11-
export interface RSCRouteConfigEntry {
12-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13-
[key: string]: any;
14-
path?: string;
15-
index?: boolean;
16-
caseSensitive?: boolean;
17-
id?: string;
18-
children?: RSCRouteConfigEntry[];
19-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
20-
lazy?: () => Promise<any>;
21-
}
22-
231
/**
242
* RSC payload types - mirrors the various payload types from react-router.
253
*/
@@ -57,17 +35,6 @@ export type DecodeFormStateFunction = (actionResult: any, body: FormData, option
5735
export type LoadServerActionFunction = (id: string) => Promise<any>;
5836
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5937
export type SSRCreateFromReadableStreamFunction = (stream: ReadableStream<Uint8Array>) => Promise<any>;
60-
export type BrowserCreateFromReadableStreamFunction = (
61-
stream: ReadableStream<Uint8Array>,
62-
options?: { temporaryReferences?: unknown },
63-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
64-
) => Promise<any>;
65-
66-
/**
67-
* Router context provider - mirrors `RouterContextProvider` from react-router.
68-
*/
69-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
70-
export type RouterContextProvider = any;
7138

7239
/**
7340
* Arguments for `unstable_matchRSCServerRequest`.
@@ -80,7 +47,8 @@ export interface MatchRSCServerRequestArgs {
8047
/** Function to decode server function arguments */
8148
decodeReply?: DecodeReplyFunction;
8249
/** Per-request context provider instance */
83-
requestContext?: RouterContextProvider;
50+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
51+
requestContext?: any;
8452
/** Function to load a server action by ID */
8553
loadServerAction?: LoadServerActionFunction;
8654
/** Function to decode server actions */
@@ -92,7 +60,8 @@ export interface MatchRSCServerRequestArgs {
9260
/** The Request to match against */
9361
request: Request;
9462
/** Route definitions */
95-
routes: RSCRouteConfigEntry[];
63+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
64+
routes: any[];
9665
/** Function to generate Response encoding the RSC payload */
9766
generateResponse: (
9867
match: RSCMatch,
@@ -128,22 +97,6 @@ export interface RouteRSCServerRequestArgs {
12897
*/
12998
export type RouteRSCServerRequestFn = (args: RouteRSCServerRequestArgs) => Promise<Response>;
13099

131-
/**
132-
* Props for `unstable_RSCHydratedRouter` component.
133-
*/
134-
export interface RSCHydratedRouterProps {
135-
/** Function to decode RSC payloads from server */
136-
createFromReadableStream: BrowserCreateFromReadableStreamFunction;
137-
/** Optional fetch implementation */
138-
fetch?: (request: Request) => Promise<Response>;
139-
/** The decoded RSC payload to hydrate */
140-
payload: RSCPayload;
141-
/** Route discovery behavior: "eager" or "lazy" */
142-
routeDiscovery?: 'eager' | 'lazy';
143-
/** Function that returns a router context provider instance */
144-
getContext?: () => RouterContextProvider;
145-
}
146-
147100
/**
148101
* Context for server component wrapping.
149102
*/

packages/react-router/src/server/rsc/wrapServerComponent.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ export function wrapServerComponent<T extends (...args: any[]) => any>(
5959
if (span) {
6060
span.setStatus({ code: SPAN_STATUS_OK });
6161
}
62-
}
63-
else if (isNotFoundResponse(error)) {
62+
} else if (isNotFoundResponse(error)) {
6463
shouldCapture = false;
6564
if (span) {
6665
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'not_found' });
6766
}
68-
}
69-
else {
67+
} else {
7068
if (span) {
7169
span.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
7270
}

packages/react-router/test/vite/makeAutoInstrumentRSCPlugin.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ describe('makeAutoInstrumentRSCPlugin', () => {
168168
const result = await plugin.load('/nonexistent/file.tsx?sentry-rsc-wrap');
169169
expect(result).toBeNull();
170170
// eslint-disable-next-line no-console
171-
expect(console.log).toHaveBeenCalledWith(
172-
expect.stringContaining('[Sentry RSC] Failed to read original file:'),
173-
);
171+
expect(console.log).toHaveBeenCalledWith(expect.stringContaining('[Sentry RSC] Failed to read original file:'));
174172
});
175173
});
176174

0 commit comments

Comments
 (0)