Fix bake codegen on windows (#17654)

This commit is contained in:
pfg
2025-02-24 19:57:35 -08:00
committed by GitHub
parent 032f99285c
commit a8c8fa15b9
3 changed files with 13 additions and 14 deletions

View File

@@ -125,6 +125,7 @@ interface CodePreview {
interface RemappedFrame extends Frame {}
declare const OVERLAY_CSS: string;
/**
* Initial mount is done lazily. The modal starts invisible, controlled
* by `setModalVisible`.
@@ -144,7 +145,7 @@ function mountModal() {
});
const shadow = domShadowRoot.attachShadow({ mode: "open" });
const sheet = new CSSStyleSheet();
sheet.replace(css("client/overlay.css", IS_BUN_DEVELOPMENT));
sheet.replace(OVERLAY_CSS);
shadow.adoptedStyleSheets = [sheet];
const root = elem("div", { class: "root" }, [

View File

@@ -1,13 +0,0 @@
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
// @ts-ignore
export async function css(file: string, is_development: boolean): string {
const { success, stdout, stderr } = await Bun.spawnSync({
cmd: [process.execPath, "build", file, "--minify"],
cwd: import.meta.dir,
stdio: ["ignore", "pipe", "pipe"],
});
if (!success) throw new Error(stderr.toString("utf-8"));
return stdout.toString("utf-8");
}

View File

@@ -30,6 +30,16 @@ function convertZigEnum(zig: string, names: string[]) {
return output;
}
function css(file: string, is_development: boolean): string {
const { success, stdout, stderr } = Bun.spawnSync({
cmd: [process.execPath, "build", file, "--minify"],
cwd: import.meta.dir,
stdio: ["ignore", "pipe", "pipe"],
});
if (!success) throw new Error(stderr.toString("utf-8"));
return stdout.toString("utf-8");
}
async function run() {
const devServerZig = readFileSync(join(base_dir, "DevServer.zig"), "utf-8");
writeIfNotChanged(join(base_dir, "generated.ts"), convertZigEnum(devServerZig, ["IncomingMessageId", "MessageId"]));
@@ -43,6 +53,7 @@ async function run() {
side: JSON.stringify(side),
IS_ERROR_RUNTIME: String(file === "error"),
IS_BUN_DEVELOPMENT: String(!!debug),
OVERLAY_CSS: css("../bake/client/overlay.css", !!debug),
},
minify: {
syntax: !debug,