Skip to content

Commit d920486

Browse files
committed
fix: #23
1 parent 1842cab commit d920486

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "elysia-react-router",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"module": "./dist/index.js",
55
"types": "./dist/index.d.ts",
66
"description": "Use React Router v7 or Remix with Elysia with HMR support!",

src/react-router.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,29 @@ export async function reactRouter(
6464
elysia.use(
6565
staticPlugin({
6666
prefix: "/",
67-
assets: "build/client",
67+
assets: join(buildDirectory, "client"),
6868
headers: { "Cache-Control": "public, max-age=31536000, immutable" },
6969
...options?.production?.assets,
7070
}),
7171
);
7272
}
7373

74-
elysia.all("*", async function processReactRouterSSR(context) {
75-
const handler = createRequestHandler(
76-
vite
77-
? await vite.ssrLoadModule("virtual:react-router/server-build")
78-
: await import(serverBuildPath),
79-
mode,
80-
);
74+
elysia.all(
75+
"*",
76+
async function processReactRouterSSR(context) {
77+
const handler = createRequestHandler(
78+
vite
79+
? await vite.ssrLoadModule("virtual:react-router/server-build")
80+
: await import(serverBuildPath),
81+
mode,
82+
);
8183

82-
const loadContext = await options?.getLoadContext?.(context);
84+
const loadContext = await options?.getLoadContext?.(context);
8385

84-
return handler(context.request, loadContext);
85-
}, { parse: 'none' });
86+
return handler(context.request, loadContext);
87+
},
88+
{ parse: "none" },
89+
);
8690

8791
return elysia;
8892
}

src/remix.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,29 @@ export async function remix(
6969
elysia.use(
7070
staticPlugin({
7171
prefix: "/",
72-
assets: "build/client",
72+
assets: join(buildDirectory, "client"),
7373
headers: { "Cache-Control": "public, max-age=31536000, immutable" },
7474
...options?.production?.assets,
7575
}),
7676
);
7777
}
7878

79-
elysia.all("*", async function processRemixSSR(context) {
80-
const handler = createRequestHandler(
81-
vite
82-
? await vite.ssrLoadModule("virtual:remix/server-build")
83-
: await import(serverBuildPath),
84-
mode,
85-
);
79+
elysia.all(
80+
"*",
81+
async function processRemixSSR(context) {
82+
const handler = createRequestHandler(
83+
vite
84+
? await vite.ssrLoadModule("virtual:remix/server-build")
85+
: await import(serverBuildPath),
86+
mode,
87+
);
8688

87-
const loadContext = await options?.getLoadContext?.(context);
89+
const loadContext = await options?.getLoadContext?.(context);
8890

89-
return handler(context.request, loadContext);
90-
});
91+
return handler(context.request, loadContext);
92+
},
93+
{ parse: "none" },
94+
);
9195

9296
return elysia;
9397
}

0 commit comments

Comments
 (0)