Backend Lambda switches from container image to ZIP via CDK NodejsFunction and esbuild

dropthejase abandoned the ARM64 Lambda container approach and moved to ZIP packaging via CDK's `NodejsFunction`, eliminating a 99-line hand-rolled deploy script and the Docker/Finch requirement for backend deploys. One specific gotcha: `pdfjs-dist` must stay in `nodeModules` because its dynamic `.mjs` import breaks esbuild bundling.

infrastructure

The migration removes Dockerfile.lambda and deletes scripts/deploy-backend.sh, which had been doing npm ci --omit=dev --os linux --cpu arm64, copying into lambda-pkg/, zipping, and calling aws lambda update-function-code. The CDK stack switches lambda.DockerImageFunction for NodejsFunction pointing directly at backend/src/lambda.ts. A cdk.context.json pins eu-west-1 AZs for reproducible synth.

The esbuild bundling config goes through several iterations. An initial nodeModules list includes pdfjs-dist, libreoffice-convert, mammoth, docx, and jszip. Then libreoffice-convert is removed from the API Lambda because conversion moved to its own dedicated Lambda. docx is removed as unused. The nodeModules list gets dropped once none of the remaining heavy deps require it - except pdfjs-dist. That one stays because its dynamic require('pdfjs-dist/legacy/build/pdf.mjs') is unsafe for esbuild to process.

The final config at 60fa124: Node 22, minify: false, sourceMap: true, @aws-sdk/client-bedrock-runtime added to externalModules to prevent bundling conflicts.

So what The "tried containers, went back to ZIP" arc is a useful data point. For your own fork, ZIP via `NodejsFunction` is the lighter-weight starting point - faster deploys, no Docker/Finch needed for developers. Watch for the `pdfjs-dist` esbuild footgun if you carry over document processing.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

7 commits from dropthejase/louis, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
1b2f80df feat: migrate backend Lambda to ZIP, bump Aurora to Postgres 17.9 Jason Lee 2026-05-11 ↗ GitHub
db5d0922 fix: use NodejsFunction for backend Lambda (esbuild, no Docker) Jason Lee 2026-05-11 ↗ GitHub
8d7ebdd1 fix: add esbuild bundling config with nodeModules for heavy deps Jason Lee 2026-05-11 ↗ GitHub
3f8db07b fix: remove unused docx dep from backend Lambda Jason Lee 2026-05-11 ↗ GitHub
09dc5767 fix: remove unnecessary nodeModules list from esbuild bundling config Jason Lee 2026-05-11 ↗ GitHub
bfae17c3 fix: keep pdfjs-dist as nodeModule (dynamic .mjs import unsafe for esbuild) Jason Lee 2026-05-11 ↗ GitHub
60fa124d chore(infra): upgrade API Lambda to Node 22, disable minify, enable source maps Jason Lee 2026-05-13 ↗ GitHub
Adds @aws-sdk/client-bedrock-runtime to externalModules to prevent
esbuild TDZ bug that caused ReferenceError on BedrockRuntimeClient init.

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-344.md from inside the repo you want the changes in.

⬇ Download capture-thread-344.md