Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/selfhost-workerd-platform-binary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"executor": patch
---

Ship the platform workerd binary in the self-host Docker runtime; without it custom app tools failed to sync or invoke with "workerd is unavailable on this platform".
25 changes: 25 additions & 0 deletions apps/host-selfhost/scripts/package-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ const libsqlNativePackage = (): string => {
return `@libsql/${target}`;
};

// The `workerd` package's bin/workerd is a Node shim that execs the real
// binary from the per-platform optional dependency
// (`@cloudflare/workerd-<os>-<arch>`); without it the runtime throws
// "workerd is unavailable on this platform" on first app-tool bundle or
// invoke. Same per-platform shape as libsql above.
const workerdPlatformPackage = (): string => {
const platformMap: Record<string, string> = {
"darwin-arm64": "workerd-darwin-arm64",
"darwin-x64": "workerd-darwin-64",
"linux-arm64": "workerd-linux-arm64",
"linux-x64": "workerd-linux-64",
"win32-x64": "workerd-windows-64",
};
const key = `${process.platform}-${process.arch}`;
const target = platformMap[key];
if (!target) {
throw new Error(
`package-runtime: no workerd platform package mapped for ${key}. ` +
"Add it to the platform map in apps/host-selfhost/scripts/package-runtime.ts.",
);
}
return `@cloudflare/${target}`;
};

const externalPackages = [
"@cloudflare/worker-bundler",
"quickjs-emscripten",
Expand All @@ -46,6 +70,7 @@ const externalPackages = [
"@jitl/quickjs-wasmfile-release-asyncify",
"@jitl/quickjs-wasmfile-debug-asyncify",
"workerd",
workerdPlatformPackage(),
libsqlNativePackage(),
] as const;

Expand Down
Loading