fix(aws-lambda): the size check on every PR measures the package a release publishes (#6017)

* fix(aws-lambda): the size check on every PR measures the package a release publishes

* style(aws-lambda): format the prebuilt template helper
This commit is contained in:
Miguel Ángel
2026-10-21 10:12:45 +00:00
committed by GitHub
parent 84f7965492
commit ccc13c3b5a
5 changed files with 27 additions and 14 deletions
+4
View File
@@ -20,6 +20,7 @@
import { build } from "esbuild";
import { execSync } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";
import { writePrebuiltTemplate } from "./scripts/prebuilt-template.mjs";
rmSync("dist", { recursive: true, force: true });
mkdirSync("dist", { recursive: true });
@@ -70,4 +71,7 @@ execSync(
{ stdio: "inherit" },
);
// The template ships in every build, so a PR packs and size-checks what a release publishes.
writePrebuiltTemplate("../..", "prebuilt");
console.log("[Build] Complete: dist/{index,handler,sdk/index,cdk/index}.js + dist/_chunks + .d.ts");
+1
View File
@@ -11,6 +11,7 @@
"dist/",
"prebuilt/",
"scripts/",
"!scripts/*.test.ts",
"README.md"
],
"type": "module",
+2 -13
View File
@@ -11,8 +11,7 @@ import {
type HandlerZipManifest,
PREBUILT_DIR,
} from "../src/sdk/prebuiltHandler.js";
const CHECKOUT_CODE_URI = "CodeUri: ../../packages/aws-lambda/dist/handler.zip";
import { writePrebuiltTemplate } from "./prebuilt-template.mjs";
export function pinHandlerZip(repoRoot: string): HandlerZipManifest {
const pkgDir = join(repoRoot, "packages", "aws-lambda");
@@ -31,18 +30,8 @@ export function pinHandlerZip(repoRoot: string): HandlerZipManifest {
const sha256 = createHash("sha256").update(bytes).digest("hex");
writeFileSync(asset.replace(/\.zip$/, ".sha256"), `${sha256} ${HANDLER_ZIP_ASSET}\n`);
const template = readFileSync(join(repoRoot, "examples", "aws-lambda", "template.yaml"), "utf-8");
if (template.split(CHECKOUT_CODE_URI).length !== 2) {
throw new Error(
`[pin-handler-zip] expected exactly one "${CHECKOUT_CODE_URI}" in the template`,
);
}
const outDir = join(pkgDir, PREBUILT_DIR);
mkdirSync(outDir, { recursive: true });
writeFileSync(
join(outDir, "template.yaml"),
template.replace(CHECKOUT_CODE_URI, "CodeUri: handler.zip"),
);
writePrebuiltTemplate(repoRoot, outDir);
const manifest: HandlerZipManifest = {
version: pkg.version,
url: `${pkg.repository.url}/releases/download/v${pkg.version}/${HANDLER_ZIP_ASSET}`,
@@ -0,0 +1,19 @@
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const CHECKOUT_CODE_URI = "CodeUri: ../../packages/aws-lambda/dist/handler.zip";
/** Writes `<outDir>/template.yaml`: the example SAM template, pointed at a `handler.zip` beside it. */
export function writePrebuiltTemplate(repoRoot, outDir) {
const template = readFileSync(join(repoRoot, "examples", "aws-lambda", "template.yaml"), "utf-8");
if (template.split(CHECKOUT_CODE_URI).length !== 2) {
throw new Error(
`[prebuilt-template] expected exactly one "${CHECKOUT_CODE_URI}" in the template`,
);
}
mkdirSync(outDir, { recursive: true });
writeFileSync(
join(outDir, "template.yaml"),
template.replace(CHECKOUT_CODE_URI, "CodeUri: handler.zip"),
);
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"@hyperframes/aws-lambda": { "packed": 70000, "unpacked": 244000 },
"@hyperframes/aws-lambda": { "packed": 70874, "unpacked": 258166 },
"@hyperframes/cli": { "packed": 7517641, "unpacked": 22401400 },
"@hyperframes/core": { "packed": 1636442, "unpacked": 3903211 },
"@hyperframes/engine": { "packed": 428347, "unpacked": 1436293 },