DEV Community

Cover image for CDK Booster - Speeding Up Bundling of Lambda Handlers
Marko - ServerlessLife.com
Marko - ServerlessLife.com

Posted on • Originally published at serverlesslife.com

CDK Booster - Speeding Up Bundling of Lambda Handlers

Stop waiting for CDK to bundle Lambda functions. CDK Booster accelerates TypeScript/JavaScript builds with seamless integration.

One of AWS Cloud Development Kit (AWS CDK)'s main drawbacks is that it executes tasks sequentially, including the bundling of Lambda code. For large projects with many functions, this can make the process painfully slow.

That’s why I created CDK Booster. It bundles all Lambda functions created with the NodejsFunction construct in one go, producing the same per-function assets CDK would normally generate. It’s a drop-in replacement: no code changes required, just installation and a small tweak to cdk.json.

CDK Booster aslo prevents double bundling. Sometimes CDK triggers synthesis twice because certain resources require lookups before they can be resolved. Normally, this would mean all Lambda functions are bundled twice as well. CDK Booster detects this and prevents unnecessary duplicate bundling.

Key Benefits

  • Much faster builds on projects with many TypeScript/JavaScript Lambda functions
  • Seamless integration – drop-in replacement, no code changes needed
  • Smarter bundling – avoids running twice during repeated synth

Setup

npm install cdk-booster
Enter fullscreen mode Exit fullscreen mode

Modify your cdk.json file:

Replace this:

{
  "app": "npx ts-node --prefer-ts-exts bin/your_app.ts",
  ...
}
Enter fullscreen mode Exit fullscreen mode

With this:

{
  "app": "npx cdk-booster bin/your_app.ts",
  ...
}
Enter fullscreen mode Exit fullscreen mode

bin/your_app.ts is location to your CDK app.

All functions created with the NodejsFunction construct are automatically bundled using CDK Booster:

import * as lambda_nodejs from "aws-cdk-lib/aws-lambda-nodejs";

const functionTestJsEsModule = new lambda_nodejs.NodejsFunction(
  this,
  "TestJsEsModule",
  {
    entry: "lambda.ts",
  }
);
Enter fullscreen mode Exit fullscreen mode

How It Works

CDK Booster operates through a multi-phase process:

  1. Transpilation – ESbuild compiles CDK code and injects discovery logic for Lambda functions.
  2. Descovery phase – CDK code runs in Node.js worker threads, identifying functions and build commands.
  3. Bundling – all handlers are bundled at once using ESbuild’s multiple entry points. This approach is what provides the significant speed improvement. Bundled assets are placed in the cdk.out/bundling-temp-* folders for CDK to consume.
  4. CDK synth – the regular CDK process runs, skipping redundant bundling since assets are ready.
  5. Asset reuse – if synth reruns (e.g., for lookups), CDK Booster reuses existing bundles.

Summary

CDK Booster shines in large projects with dozens of Lambda functions, where sequential bundling can significantly slow down the build process. For smaller applications, the speedup is less dramatic but still helpful.

Note that bundling itself is rarely the slowest step in deployment—most of the time is consumed by CloudFormation. CDK Booster targets the bundling phase specifically, making it faster and avoiding duplicate work when synthesis runs more than once.

The result is a leaner, more efficient development workflow: less waiting, quicker feedback, and more time to focus on building features instead of watching your code bundle.

Top comments (0)