Skip to content

Commit 58ff44e

Browse files
committed
fix(wdmock): ビルド順序とcleanスクリプトの修正
- クライアントビルドを先に実行してmanifest.jsonを生成 - Top-level awaitを静的importに変更してViteビルドエラーを解消 - cleanスクリプトを追加(dist, .wrangler削除)
1 parent bb4a7b4 commit 58ff44e

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

examples/wdmock-cf/apps/main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "vite build && vite build --mode client",
8+
"build": "vite build --mode client && vite build",
99
"preview": "wrangler pages dev",
1010
"deploy": "bun run build && wrangler pages deploy dist",
1111
"typecheck": "bunx tsc --noEmit"

examples/wdmock-cf/apps/main/src/client-manifest.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,14 @@ type ManifestEntry = {
77
isEntry?: boolean;
88
};
99

10-
let manifest: Record<string, ManifestEntry> | null = null;
10+
type Manifest = Record<string, ManifestEntry>;
1111

12-
try {
13-
// @ts-expect-error manifest.json only exists after build
14-
manifest = await import("../dist/.vite/manifest.json");
15-
} catch {
16-
// Ignore - manifest doesn't exist during development/typecheck
17-
}
12+
// @ts-expect-error manifest.json only exists after client build
13+
import manifest from "../dist/.vite/manifest.json" with { type: "json" };
1814

1915
export function getClientScriptPath(): string {
20-
if (!manifest) {
21-
throw new Error("Manifest not found - run build first");
22-
}
23-
const entry = manifest["src/client/main.ts"];
16+
const m = manifest as Manifest;
17+
const entry = m["src/client/main.ts"];
2418
if (!entry) {
2519
throw new Error("Client entry not found in manifest");
2620
}

examples/wdmock-cf/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"type": "module",
99
"scripts": {
10+
"clean": "rm -rf apps/*/dist apps/*/.wrangler",
1011
"dev": "bun run --filter @wdmock/main dev",
1112
"dev:files": "bun run --filter @wdmock/files dev",
1213
"dev:all": "bun run dev & bun run dev:files",

0 commit comments

Comments
 (0)