GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/services/data/script/build.ts at dev · MervinPraison/opencode Expand file tree/ Copy pathbuild.tsMore file actions 101 lines (93 loc) · 3.93 KB / Copy pathbuild.tsFile metadata and controls101 lines (93 loc) · 3.93 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 // Builds the data site's three Workers into one Build Output Specification tree (.cloudflare/output) for // `cf deploy --prebuilt --worker <dir>` (script/deploy.ts): // - default: the SolidStart site (packages/data/app, Nitro's cloudflare-module preset) with .output/public as assets // - og: the Open Graph image Worker, whose Wasm engines and fonts ship as modules // - sync: the DataSyncWorkflow and its cron handler (packages/data/server) // cf's own build step can't detect these projects, so they deploy prebuilt. // // bun script/build.ts --mode dev|production import { cp, mkdir, readdir } from "node:fs/promises" import path from "node:path" import { cleanBuildOutputDir, getWorkerBundleDir, writeAssets, writeRootConfig, writeWorkerConfig, } from "@cloudflare/build-output-utils" import { resolveAndParseConfig } from "@cloudflare/config" import { stage } from "../stage" const root = path.resolve(import.meta.dir, "..") const app = path.resolve(root, "../../packages/data/app") const server = path.resolve(root, "../../packages/data/server") const modeIndex = process.argv.indexOf("--mode") const mode = stage(modeIndex === -1 ? undefined : process.argv[modeIndex + 1]) // STAGE picks the stage's headers for the static assets (packages/data/app/src/lib/noindex.ts). const env = { ...process.env, STAGE: mode } await Bun.$`bun run build`.cwd(app).env(env) await Bun.$`bun run build:og`.cwd(app).env(env) // @cloudflare/config's file loader refuses Bun; it resolves an imported config the same way. async function resolve(file: string) { const parsed = await resolveAndParseConfig((await import(file)).default, { isPreview: false, mode }) if (!parsed.success) throw new Error(`${file}: ${parsed.error.message}`) if (!parsed.data.worker) throw new Error(`${file} defines no worker`) return { ...parsed.data, worker: parsed.data.worker } } const site = await resolve("../cloudflare.config") const og = await resolve("../og.config") const sync = await resolve("../sync.config") await cleanBuildOutputDir(root) await writeRootConfig( root, { accountId: site.accountId, complianceRegion: site.complianceRegion }, { isPreview: false, mode }, ) // The site: Nitro's server bundle and public directory. await writeAssets({ root, sourceDirectory: path.join(app, ".output", "public") }) await cp(path.join(app, ".output", "server"), getWorkerBundleDir(root), { recursive: true, filter: (file) => !file.endsWith("wrangler.json") && !file.endsWith(".map"), }) await writeWorkerConfig({ root, config: site.worker, manifest: { type: "partial", mainModule: "index.mjs", modules: {} }, }) // The OG Worker: its bundle plus the Wasm and font modules it imports. const ogFiles = await readdir(path.join(app, ".og-worker")) await mkdir(getWorkerBundleDir(root, "og"), { recursive: true }) await cp(path.join(app, ".og-worker"), getWorkerBundleDir(root, "og"), { recursive: true }) await writeWorkerConfig({ root, directoryName: "og", config: og.worker, manifest: { type: "partial", mainModule: "index.mjs", modules: Object.fromEntries( ogFiles.flatMap((file): [string, { type: "wasm" | "data" }][] => { if (file.endsWith(".wasm")) return [[file, { type: "wasm" }]] if (file.endsWith(".bin")) return [[file, { type: "data" }]] return [] }), ), }, }) // The sync Worker, bundled for workerd. const result = await Bun.build({ entrypoints: [path.join(server, "src/worker.ts")], outdir: getWorkerBundleDir(root, "sync"), naming: "index.mjs", target: "browser", format: "esm", conditions: ["workerd", "worker", "browser"], external: ["cloudflare:*", "node:*"], }) if (!result.success) throw new AggregateError(result.logs, "The sync Worker failed to build") await writeWorkerConfig({ root, directoryName: "sync", config: sync.worker, manifest: { type: "partial", mainModule: "index.mjs", modules: {} }, }) console.log(`data: built ${site.worker.name}, ${og.worker.name} and ${sync.worker.name} (${mode})`) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |