Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/lang/bun/files/patch-src_codegen_bake-codegen.ts
46591 views
1
-- Replace Bun.spawnSync with async Bun.spawn in bake-codegen.
2
-- On FreeBSD linux compat layer, Bun.spawnSync with stdio:"pipe" fails
3
-- with EINVAL because pread() is not valid on pipes. Using async Bun.spawn
4
-- with Response.arrayBuffer() works correctly on FreeBSD linux compat.
5
6
2026-04-27 07:15:02 UTC
7
+++ src/codegen/bake-codegen.ts
8
@@ -30,20 +30,27 @@ function convertZigEnum(zig: string, names: string[])
9
return output;
10
}
11
12
-function css(file: string, is_development: boolean): string {
13
- const { success, stdout, stderr } = Bun.spawnSync({
14
+async function css(file: string, is_development: boolean): Promise<string> {
15
+ const proc = Bun.spawn({
16
cmd: [process.execPath, "build", file, "--minify"],
17
cwd: import.meta.dir,
18
stdio: ["ignore", "pipe", "pipe"],
19
});
20
- if (!success) throw new Error(stderr.toString("utf-8"));
21
- return stdout.toString("utf-8");
22
+ const [stdoutBuf, stderrBuf] = await Promise.all([
23
+ new Response(proc.stdout).arrayBuffer(),
24
+ new Response(proc.stderr).arrayBuffer(),
25
+ ]);
26
+ const exitCode = await proc.exited;
27
+ if (exitCode !== 0) throw new Error(Buffer.from(stderrBuf).toString("utf-8"));
28
+ return Buffer.from(stdoutBuf).toString("utf-8");
29
}
30
31
async function run() {
32
const devServerZig = readFileSync(join(base_dir, "DevServer.zig"), "utf-8");
33
writeIfNotChanged(join(base_dir, "generated.ts"), convertZigEnum(devServerZig, ["IncomingMessageId", "MessageId"]));
34
35
+ const overlayCSS = await css("../bake/client/overlay.css", !!debug);
36
+
37
const results = await Promise.allSettled(
38
["client", "server", "error"].map(async file => {
39
const side = file === "error" ? "client" : file;
40
@@ -53,7 +60,7 @@ async function run() {
41
side: JSON.stringify(side),
42
IS_ERROR_RUNTIME: String(file === "error"),
43
IS_BUN_DEVELOPMENT: String(!!debug),
44
- OVERLAY_CSS: css("../bake/client/overlay.css", !!debug),
45
+ OVERLAY_CSS: overlayCSS,
46
},
47
minify: {
48
syntax: !debug,
49
50