From 3cd8a566a2ada03450105ffd9bcd44f24fa6d4e7 Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Fri, 27 Mar 2026 07:48:08 +1000 Subject: [PATCH 1/2] fix: web ui bundle build on windows --- packages/opencode/script/build.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index 653c67d8de7a..b4e6c879d341 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -68,17 +68,24 @@ const skipEmbedWebUi = process.argv.includes("--skip-embed-web-ui") const createEmbeddedWebUIBundle = async () => { console.log(`Building Web UI to embed in the binary`) const appDir = path.join(import.meta.dirname, "../../app") + const dist = path.join(appDir, "dist") await $`bun run --cwd ${appDir} build` - const allFiles = await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: path.join(appDir, "dist") })) - const fileMap = ` - // Import all files as file_$i with type: "file" - ${allFiles.map((filePath, i) => `import file_${i} from "${path.join(appDir, "dist", filePath)}" with { type: "file" };`).join("\n")} - // Export with original mappings - export default { - ${allFiles.map((filePath, i) => `"${filePath}": file_${i},`).join("\n")} - } - `.trim() - return fileMap + const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist }))).map((file) => + file.replaceAll("\\", "/"), + ) + const imports = files.map((file, i) => { + const spec = path.relative(dir, path.join(dist, file)).replaceAll("\\", "/") + return `import file_${i} from ${JSON.stringify(spec.startsWith(".") ? spec : `./${spec}`)} with { type: "file" };` + }) + const entries = files.map((file, i) => ` ${JSON.stringify(file)}: file_${i},`) + return [ + `// Import all files as file_$i with type: "file"`, + ...imports, + `// Export with original mappings`, + `export default {`, + ...entries, + `}`, + ].join("\n") } const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle() From 0c958b25e7632ca17db3ef14de94a58d35bd460a Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Fri, 27 Mar 2026 08:07:56 +1000 Subject: [PATCH 2/2] sort glob results for reproducible builds --- packages/opencode/script/build.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index b4e6c879d341..7341810768c9 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -70,9 +70,9 @@ const createEmbeddedWebUIBundle = async () => { const appDir = path.join(import.meta.dirname, "../../app") const dist = path.join(appDir, "dist") await $`bun run --cwd ${appDir} build` - const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist }))).map((file) => - file.replaceAll("\\", "/"), - ) + const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist }))) + .map((file) => file.replaceAll("\\", "/")) + .sort() const imports = files.map((file, i) => { const spec = path.relative(dir, path.join(dist, file)).replaceAll("\\", "/") return `import file_${i} from ${JSON.stringify(spec.startsWith(".") ? spec : `./${spec}`)} with { type: "file" };`