From bf0ade34c79591336f98debbab0d232b81e2d2ed Mon Sep 17 00:00:00 2001 From: Alex Holtz Date: Thu, 15 Oct 2026 18:11:53 -0500 Subject: [PATCH 1/4] test(ci): smoke test loading the Lambda bundle as Lambda does Load build/proxy.js with Node 20 from a directory containing only the files publish.yaml zips, so the repo-root package.json cannot mark it as an ES module, and with module syntax detection disabled. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/test.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 20e5099..c1aba5a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,24 @@ jobs: - name: Build run: bun run build + - name: Setup Node + uses: actions/setup-node@v7 + with: + # Keep in sync with the Lambda runtime in lambda.tf + node-version: 20 + + - name: Smoke Test Lambda Bundle + # Load the bundle from a directory holding only what publish.yaml zips, so the repo's + # package.json can't mark it as ESM. Module syntax detection is disabled to match Lambda. + run: | + mkdir -p "$RUNNER_TEMP/lambda" + cp -r build node_modules "$RUNNER_TEMP/lambda/" + cd "$RUNNER_TEMP/lambda" + node --no-experimental-detect-module --input-type=module -e " + const { handler } = await import('./build/proxy.js'); + if (typeof handler !== 'function') throw new Error('build/proxy.js does not export handler'); + " + - name: Test run: bun run test From 923e84f2575a69732d64990ce46372c5c454a300 Mon Sep 17 00:00:00 2001 From: Alex Holtz Date: Thu, 15 Oct 2026 18:14:52 -0500 Subject: [PATCH 2/4] fix(build): mark Lambda bundle as an ES module bun build emits build/proxy.js as ESM, but proxy-lambda.zip contains only build/ and node_modules/, so Lambda loads it as CommonJS and fails init with "Cannot use import statement outside a module". Write build/package.json with "type": "module" so it ships in the zip. Affects releases v2.3.0 through v2.4.3. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 516f27f..58979cb 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "lambdas/proxy/index.js", "type": "module", "scripts": { - "build": "bun build lambda/proxy.ts --outdir build/ --target node", + "build": "bun build lambda/proxy.ts --outdir build/ --target node && echo '{\"type\": \"module\"}' > build/package.json", "format": "prettier --write .", "format-check": "prettier --check .", "test": "bun test" From 90918717feb5be7315d91843c054fe5bb8ba2581 Mon Sep 17 00:00:00 2001 From: Alex Holtz Date: Fri, 16 Oct 2026 12:42:47 -0500 Subject: [PATCH 3/4] test(ci): smoke test the packaged zip by requiring the handler as CommonJS Packages through a shared package script (also used by publish.yaml), unzips it, and requires build/proxy.js on Node 20 with require(esm) and module syntax detection turned off. This tests the real artifact and requires the bundle itself to be CommonJS, so it fails against the current ESM bundle. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish.yaml | 2 +- .github/workflows/test.yaml | 13 ++++++------- package.json | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 92c4360..dc74266 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -28,7 +28,7 @@ jobs: run: curl https://curl.se/ca/cacert.pem -o build/public-certs.pem - name: Zip Lambda - run: zip -r -qq proxy-lambda.zip build node_modules + run: bun run package - name: Upload Release Assets uses: softprops/action-gh-release@v3 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c1aba5a..f893afc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,15 +36,14 @@ jobs: node-version: 20 - name: Smoke Test Lambda Bundle - # Load the bundle from a directory holding only what publish.yaml zips, so the repo's - # package.json can't mark it as ESM. Module syntax detection is disabled to match Lambda. + # Load the handler from the packaged zip the way Lambda does: as CommonJS, with + # require(esm) and module syntax detection off, so an ESM bundle fails here too. run: | - mkdir -p "$RUNNER_TEMP/lambda" - cp -r build node_modules "$RUNNER_TEMP/lambda/" + bun run package + unzip -q proxy-lambda.zip -d "$RUNNER_TEMP/lambda" cd "$RUNNER_TEMP/lambda" - node --no-experimental-detect-module --input-type=module -e " - const { handler } = await import('./build/proxy.js'); - if (typeof handler !== 'function') throw new Error('build/proxy.js does not export handler'); + node --no-experimental-require-module --no-experimental-detect-module -e " + if (typeof require('./build/proxy.js').handler !== 'function') throw new Error('build/proxy.js does not export handler'); " - name: Test diff --git a/package.json b/package.json index 58979cb..f8e554b 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "build": "bun build lambda/proxy.ts --outdir build/ --target node && echo '{\"type\": \"module\"}' > build/package.json", + "package": "zip -r -qq proxy-lambda.zip build node_modules", "format": "prettier --write .", "format-check": "prettier --check .", "test": "bun test" From 000547141a077a8bf0c3f291e603f3821087b822 Mon Sep 17 00:00:00 2001 From: Alex Holtz Date: Fri, 16 Oct 2026 12:43:03 -0500 Subject: [PATCH 4/4] fix(build): bundle the Lambda handler as CommonJS Replaces the generated build/package.json with a CommonJS bundle, so build/proxy.js loads on Lambda without depending on a sidecar file. This matches the format v2.1.0 shipped. Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f8e554b..40dedf2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "lambdas/proxy/index.js", "type": "module", "scripts": { - "build": "bun build lambda/proxy.ts --outdir build/ --target node && echo '{\"type\": \"module\"}' > build/package.json", + "build": "bun build lambda/proxy.ts --outdir build/ --target node --format cjs", "package": "zip -r -qq proxy-lambda.zip build node_modules", "format": "prettier --write .", "format-check": "prettier --check .",