Skip to content

Commit 8bacd5d

Browse files
tylersayshidai-shi
andauthored
refactor: fs-router to use new_createPages & fix staticPaths (#1003)
Changes: - pages are built in slices of 2500 to avoid running out of memory when running `Promise.all` - this moves fs-router to use new_createPages --------- Co-authored-by: Tyler <[email protected]> Co-authored-by: Daishi Kato <[email protected]>
1 parent ffa5eec commit 8bacd5d

File tree

10 files changed

+279
-289
lines changed

10 files changed

+279
-289
lines changed
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { getPath } from './context.js';
2-
3-
export function Path() {
4-
return <h1>{getPath()}</h1>;
1+
export function Path({ path }: { path: string }) {
2+
return <h1>{path}</h1>;
53
}

e2e/fixtures/ssg-performance/src/context.ts

-17
This file was deleted.

e2e/fixtures/ssg-performance/src/pages/[path].tsx e2e/fixtures/ssg-performance/src/pages/[slug].tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import type { PageProps } from 'waku/router';
12
import { Path } from '../Path.js';
23

3-
export default async function Test() {
4+
export default async function Test({ path }: PageProps<'/[slug]'>) {
45
await new Promise((resolve) => setTimeout(resolve, 1000));
5-
return <Path />;
6+
return <Path path={path} />;
67
}
78

89
export async function getConfig() {
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import type { PropsWithChildren } from 'react';
2-
import { setPath } from '../context.js';
32

4-
export default function Layout({
5-
children,
6-
path,
7-
}: PropsWithChildren<{ path: string }>) {
8-
setPath(path);
9-
return children;
3+
export default function Layout({ children }: PropsWithChildren) {
4+
return <div>{children}</div>;
105
}

e2e/fixtures/ssg-wildcard/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "waku-example",
2+
"name": "ssg-wildcard",
33
"version": "0.1.0",
44
"type": "module",
55
"private": true,

examples/11_fs-router/src/main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StrictMode } from 'react';
22
import { createRoot, hydrateRoot } from 'react-dom/client';
3-
import { Router } from 'waku/router/client';
3+
import { NewRouter as Router } from 'waku/router/client';
44

55
const rootElement = (
66
<StrictMode>

examples/44_cloudflare/waku.cloudflare-dev-server.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ export const cloudflareDevServer = (cfOptions: any) => {
99
Object.assign(globalThis, { WebSocketPair });
1010
});
1111
return async (req: Request, app: Hono<BlankEnv, BlankSchema>) => {
12-
const [proxy, _] = await Promise.all([
13-
await wranglerPromise,
14-
await miniflarePromise,
15-
]);
12+
const [proxy, _] = await Promise.all([wranglerPromise, miniflarePromise]);
1613
Object.assign(req, { cf: proxy.cf });
1714
Object.assign(globalThis, {
1815
caches: proxy.caches,

0 commit comments

Comments
 (0)