From 405189953300ec8f5a08a6ce6d5cd649920d6732 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 17 May 2026 19:16:56 +0000 Subject: [PATCH] chore(lambda): publish-readiness for @hyperframes/aws-lambda MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Lambda adapter has been on `main` since PR #909 but its package manifest still shipped TypeScript source (`main: ./src/index.ts`, `build: tsc --noEmit`, `version: 0.0.1`) and the publish workflow didn't list it. This wires it up to publish alongside the other `@hyperframes/*` packages on the next `v*` tag. Changes: - **packages/aws-lambda/build.mjs (new)** — mirrors `packages/producer/build.mjs`: esbuild bundles four entry points (`src/index.ts`, `src/handler.ts`, `src/sdk/index.ts`, `src/cdk/index.ts`) → `dist/`, then `tsc --emitDeclarationOnly` emits .d.ts via `tsconfig.build.json`. All runtime/peer deps (@aws-sdk/*, @hyperframes/producer*, @sparticuz/chromium, aws-cdk-lib, constructs, ffmpeg-static, ffprobe-static, puppeteer-core, tar) are external so consumers resolve them through their own node_modules. - **packages/aws-lambda/tsconfig.build.json (new)** — drops the workspace `paths` overrides so `@hyperframes/producer*` resolves through node_modules to producer's already-built `dist/` types instead of pulling its full source tree into emit (which would violate `rootDir`). - **packages/aws-lambda/tsconfig.json** — keeps `noEmit: true` + workspace `paths` for fast in-place typechecks; also excludes `src/**/__fixtures__/**` so test-only helpers (fakeS3) don't leak into emitted declarations. - **packages/aws-lambda/package.json**: * version bumped 0.0.1 → 0.6.18 (matches the repo's lockstep release cadence) * main / types / exports map points at `dist/...` * files: ["dist/", "scripts/", "README.md"] (scripts/ kept whole because build-zip.ts and verify-zip-size.ts both import scripts/_formatBytes.ts) * scripts.build = `node build.mjs` - **package.json** — root `build` filter includes `aws-lambda` so `bun run build` builds it in topological order after producer. - **.github/workflows/publish.yml** — one new `publish_pkg "@hyperframes/aws-lambda" "@hyperframes/aws-lambda"` line. First publish is automatic via the `--access public` flag in `publish_pkg`; the @hyperframes scope already owns the name. Verification: bun run build # full root build green bun run verify:packed-manifests # aws-lambda passes pnpm pack packages/cli # @hyperframes/aws-lambda # rewrites workspace:* → 0.6.18 npm install -g # smoke-install still works hyperframes lambda deploy # friendly missing-package # error still fires when # aws-lambda isn't installed --- .github/workflows/publish.yml | 1 + package.json | 2 +- packages/aws-lambda/build.mjs | 62 +++++++++++++++++++++++++ packages/aws-lambda/package.json | 30 ++++++++---- packages/aws-lambda/tsconfig.build.json | 12 +++++ packages/aws-lambda/tsconfig.json | 2 +- 6 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 packages/aws-lambda/build.mjs create mode 100644 packages/aws-lambda/tsconfig.build.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6b01b164be..9f9fd2a823 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -130,6 +130,7 @@ jobs: publish_pkg "@hyperframes/producer" "@hyperframes/producer" publish_pkg "@hyperframes/shader-transitions" "@hyperframes/shader-transitions" publish_pkg "@hyperframes/studio" "@hyperframes/studio" + publish_pkg "@hyperframes/aws-lambda" "@hyperframes/aws-lambda" # CLI is @hyperframes/cli in the monorepo but published as unscoped "hyperframes" on npm. # Rewrite the name in package.json before publishing, then use npm publish directly diff --git a/package.json b/package.json index 916af0bde9..11ac3ade0b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "type": "module", "scripts": { "dev": "bun run studio", - "build": "bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{core,engine,producer,player,studio,shader-transitions}' build && bun run --filter @hyperframes/cli build", + "build": "bun run --filter @hyperframes/core build && bun run --filter '@hyperframes/{core,engine,producer,player,studio,shader-transitions,aws-lambda}' build && bun run --filter @hyperframes/cli build", "build:producer": "bun run --filter @hyperframes/producer build", "studio": "bun run --filter @hyperframes/studio dev", "build:hyperframes-runtime": "bun run --filter @hyperframes/core build:hyperframes-runtime", diff --git a/packages/aws-lambda/build.mjs b/packages/aws-lambda/build.mjs new file mode 100644 index 0000000000..f6918a2480 --- /dev/null +++ b/packages/aws-lambda/build.mjs @@ -0,0 +1,62 @@ +#!/usr/bin/env node +/** + * Build script for @hyperframes/aws-lambda (public OSS package). + * + * Bundles each subpath barrel via esbuild → dist/, then emits .d.ts via tsc. + * + * Subpaths (each gets its own dist entry so adopters that import one path + * don't load the others' transitive graphs at module-load time): + * + * . (the umbrella barrel: handler + sdk + cdk types re-exported) + * ./handler (the Lambda runtime entry — what `scripts/build-zip.ts` ZIPs) + * ./sdk (client-side helpers — AWS-SDK only, no chromium/puppeteer) + * ./cdk (CDK L2 construct — aws-cdk-lib is a peer dep) + * + * All production deps and peer deps are kept external so consumers resolve + * them via their own node_modules. + */ + +import { build } from "esbuild"; +import { execSync } from "node:child_process"; +import { mkdirSync, rmSync } from "node:fs"; + +rmSync("dist", { recursive: true, force: true }); +mkdirSync("dist", { recursive: true }); + +const sharedOpts = { + bundle: true, + platform: "node", + target: "node22", + format: "esm", + minify: false, + sourcemap: true, + external: [ + "@aws-sdk/client-s3", + "@aws-sdk/client-sfn", + "@hyperframes/producer", + "@hyperframes/producer/distributed", + "@sparticuz/chromium", + "aws-cdk-lib", + "constructs", + "ffmpeg-static", + "ffprobe-static", + "puppeteer-core", + "tar", + ], +}; + +await Promise.all([ + build({ ...sharedOpts, entryPoints: ["src/index.ts"], outfile: "dist/index.js" }), + build({ ...sharedOpts, entryPoints: ["src/handler.ts"], outfile: "dist/handler.js" }), + build({ ...sharedOpts, entryPoints: ["src/sdk/index.ts"], outfile: "dist/sdk/index.js" }), + build({ ...sharedOpts, entryPoints: ["src/cdk/index.ts"], outfile: "dist/cdk/index.js" }), +]); + +// esbuild doesn't emit .d.ts. tsc does, with a build-only tsconfig that +// drops the workspace `paths` overrides so `@hyperframes/producer` resolves +// through node_modules to the sibling package's already-built `dist/` +// types instead of pulling its full source tree into emit (which would +// violate rootDir). +execSync("tsc -p tsconfig.build.json --emitDeclarationOnly", { stdio: "inherit" }); + +console.log("[Build] Complete: dist/{index,handler,sdk/index,cdk/index}.js + .d.ts"); diff --git a/packages/aws-lambda/package.json b/packages/aws-lambda/package.json index a94e096249..c027624e77 100644 --- a/packages/aws-lambda/package.json +++ b/packages/aws-lambda/package.json @@ -1,6 +1,6 @@ { "name": "@hyperframes/aws-lambda", - "version": "0.0.1", + "version": "0.6.18", "description": "AWS Lambda adapter for HyperFrames distributed rendering — handler, client-side SDK, and CDK construct.", "repository": { "type": "git", @@ -8,25 +8,37 @@ "directory": "packages/aws-lambda" }, "files": [ - "src/", + "dist/", "scripts/", "README.md" ], "type": "module", - "main": "./src/index.ts", - "types": "./src/index.ts", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { - ".": "./src/index.ts", - "./handler": "./src/handler.ts", - "./sdk": "./src/sdk/index.ts", - "./cdk": "./src/cdk/index.ts" + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./handler": { + "import": "./dist/handler.js", + "types": "./dist/handler.d.ts" + }, + "./sdk": { + "import": "./dist/sdk/index.js", + "types": "./dist/sdk/index.d.ts" + }, + "./cdk": { + "import": "./dist/cdk/index.js", + "types": "./dist/cdk/index.d.ts" + } }, "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" }, "scripts": { - "build": "tsc --noEmit", + "build": "node build.mjs", "build:zip": "tsx scripts/build-zip.ts", "probe:beginframe": "tsx scripts/probe-beginframe.ts", "probe:beginframe:docker": "docker build -f scripts/probe-beginframe.dockerfile -t hyperframes-lambda-probe:local ../.. && docker run --rm hyperframes-lambda-probe:local", diff --git a/packages/aws-lambda/tsconfig.build.json b/packages/aws-lambda/tsconfig.build.json new file mode 100644 index 0000000000..c93bd474e6 --- /dev/null +++ b/packages/aws-lambda/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "paths": {}, + "noEmit": false, + "outDir": "./dist", + "rootDir": "./src", + "declaration": true, + "declarationMap": true, + "sourceMap": true + } +} diff --git a/packages/aws-lambda/tsconfig.json b/packages/aws-lambda/tsconfig.json index faa4cf6d78..b15c984cb9 100644 --- a/packages/aws-lambda/tsconfig.json +++ b/packages/aws-lambda/tsconfig.json @@ -15,5 +15,5 @@ } }, "include": ["src/**/*"], - "exclude": ["node_modules", "dist", "src/**/*.test.ts", "scripts"] + "exclude": ["node_modules", "dist", "src/**/*.test.ts", "src/**/__fixtures__/**", "scripts"] }