Skip to content

Commit c024e5d

Browse files
committed
fix(playground): externalize project libraries and YAML in ESM bundle
1 parent 2b407f9 commit c024e5d

4 files changed

Lines changed: 59 additions & 7 deletions

File tree

bun.lock

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/playground/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@
4242
"dependencies": {
4343
"@hono/node-server": "^2.0.5",
4444
"@hono/zod-openapi": "^1.4.0",
45+
"@openagentpack/project-versions": "workspace:*",
46+
"@openagentpack/project-workspace": "workspace:*",
4547
"@openagentpack/sdk": "workspace:*",
4648
"chokidar": "^4.0.3",
4749
"hono": "^4.12.28",
50+
"yaml": "^2.9.0",
4851
"zod": "^4.4.3"
4952
},
5053
"devDependencies": {

packages/playground/tsup.config.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ export default defineConfig({
1313
// Shared singletons must resolve to one runtime instance: @hono/zod-openapi patches zod's
1414
// prototype with `.openapi()`, and the external @openagentpack/sdk builds its schemas from the same
1515
// zod — bundling a second copy would leave sdk's schemas without the patch.
16-
external: ["@openagentpack/sdk", "hono", "@hono/node-server", "@hono/zod-openapi", "zod"],
16+
// Server sources also import the public project libraries and YAML. Load these as
17+
// declared runtime dependencies: inlining YAML's CommonJS entry into ESM leaves
18+
// require("process") without Node's CommonJS loader.
19+
external: [
20+
"@openagentpack/sdk",
21+
"@openagentpack/project-versions",
22+
"@openagentpack/project-workspace",
23+
"hono",
24+
"@hono/node-server",
25+
"@hono/zod-openapi",
26+
"yaml",
27+
"zod",
28+
],
1729
// Inline the private workspace packages so the published artifact is self-contained.
1830
noExternal: [/@openagentpack\/server/],
1931
esbuildOptions(options) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { describe, expect, test } from "bun:test";
2+
import { readFileSync } from "node:fs";
3+
import playgroundConfig from "../../packages/playground/tsup.config.ts";
4+
5+
function runtimeDependencies(relativePath: string): Record<string, string> {
6+
const manifest = JSON.parse(readFileSync(new URL(relativePath, import.meta.url), "utf8")) as {
7+
dependencies: Record<string, string>;
8+
};
9+
return manifest.dependencies;
10+
}
11+
12+
describe("published Playground dependency boundary", () => {
13+
test("declares the bundled private Server's runtime dependencies", () => {
14+
const serverDependencies = runtimeDependencies("../../apps/server/package.json");
15+
const playgroundDependencies = runtimeDependencies("../../packages/playground/package.json");
16+
for (const [name, versionRange] of Object.entries(serverDependencies)) {
17+
expect(playgroundDependencies[name]).toBe(versionRange);
18+
}
19+
});
20+
21+
test("keeps public project libraries and CommonJS YAML external to the ESM bundle", () => {
22+
if (typeof playgroundConfig === "function" || Array.isArray(playgroundConfig)) {
23+
throw new Error("Expected a single Playground build configuration");
24+
}
25+
for (const name of [
26+
"@openagentpack/sdk",
27+
"@openagentpack/project-versions",
28+
"@openagentpack/project-workspace",
29+
"yaml",
30+
]) {
31+
expect(playgroundConfig.external).toContain(name);
32+
}
33+
});
34+
});

0 commit comments

Comments
 (0)