Skip to content

Commit 1953c2f

Browse files
refactor: improve type safety in server component loading and streamline import statements
1 parent 66f9714 commit 1953c2f

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

node_package/src/ReactOnRailsRSC.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { renderToPipeableStream } from 'react-on-rails-rsc/server.node';
22
import { PassThrough, Readable } from 'stream';
33

4-
import { RSCRenderParams, StreamRenderState, StreamableComponentResult } from './types/index.ts';
4+
import {
5+
RSCRenderParams,
6+
RailsContextWithComponentSpecificMetadata,
7+
StreamRenderState,
8+
StreamableComponentResult,
9+
} from './types/index.ts';
510
import ReactOnRails from './ReactOnRails.full.ts';
611
import buildConsoleReplay from './buildConsoleReplay.ts';
712
import handleError from './handleError.ts';

node_package/src/getReactServerComponent.server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const createSSRManifest = async (
3737
reactClientManifestFileName: string,
3838
) => {
3939
const [reactServerManifest, reactClientManifest] = await Promise.all([
40-
loadJsonFile(reactServerManifestFileName) as Promise<Record<string, { id: string; chunks: string[] }>>,
41-
loadJsonFile(reactClientManifestFileName) as Promise<Record<string, { id: string }>>,
40+
loadJsonFile<Record<string, { id: string; chunks: string[] }>>(reactServerManifestFileName),
41+
loadJsonFile<Record<string, { id: string }>>(reactClientManifestFileName),
4242
]);
4343

4444
const moduleMap: Record<string, unknown> = {};

node_package/src/postSSRHooks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RailsContextWithComponentSpecificMetadata } from "./types/index.ts";
1+
import { RailsContextWithComponentSpecificMetadata } from './types/index.ts';
22

33
type PostSSRHook = () => void;
44
const postSSRHooks = new Map<string, PostSSRHook[]>();

node_package/src/streamServerRenderedReactComponent.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import buildConsoleReplay from './buildConsoleReplay.ts';
88
import handleError from './handleError.ts';
99
import { renderToPipeableStream, PipeableStream } from './ReactDOMServer.cts';
1010
import { createResultObject, convertToError, validateComponent } from './serverRenderUtils.ts';
11-
import type { RenderParams, StreamRenderState, StreamableComponentResult } from './types/index.ts';
11+
import type {
12+
RailsContextWithComponentSpecificMetadata,
13+
RenderParams,
14+
StreamRenderState,
15+
StreamableComponentResult,
16+
} from './types/index.ts';
1217
import injectRSCPayload from './injectRSCPayload.ts';
1318
import { notifySSREnd } from './postSSRHooks.ts';
1419

0 commit comments

Comments
 (0)