fix: web ui bundle build on windows (#19337)

This commit is contained in:
Luke Parker
2026-03-27 08:14:20 +10:00
committed by GitHub
parent b7a06e1939
commit ef7d1f7efa

View File

@@ -68,17 +68,24 @@ const skipEmbedWebUi = process.argv.includes("--skip-embed-web-ui")
const createEmbeddedWebUIBundle = async () => { const createEmbeddedWebUIBundle = async () => {
console.log(`Building Web UI to embed in the binary`) console.log(`Building Web UI to embed in the binary`)
const appDir = path.join(import.meta.dirname, "../../app") const appDir = path.join(import.meta.dirname, "../../app")
const dist = path.join(appDir, "dist")
await $`bun run --cwd ${appDir} build` await $`bun run --cwd ${appDir} build`
const allFiles = await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: path.join(appDir, "dist") })) const files = (await Array.fromAsync(new Bun.Glob("**/*").scan({ cwd: dist })))
const fileMap = ` .map((file) => file.replaceAll("\\", "/"))
// Import all files as file_$i with type: "file" .sort()
${allFiles.map((filePath, i) => `import file_${i} from "${path.join(appDir, "dist", filePath)}" with { type: "file" };`).join("\n")} const imports = files.map((file, i) => {
// Export with original mappings const spec = path.relative(dir, path.join(dist, file)).replaceAll("\\", "/")
export default { return `import file_${i} from ${JSON.stringify(spec.startsWith(".") ? spec : `./${spec}`)} with { type: "file" };`
${allFiles.map((filePath, i) => `"${filePath}": file_${i},`).join("\n")} })
} const entries = files.map((file, i) => ` ${JSON.stringify(file)}: file_${i},`)
`.trim() return [
return fileMap `// 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() const embeddedFileMap = skipEmbedWebUi ? null : await createEmbeddedWebUIBundle()