CDK Bundler

1.0.12 · active · verified Tue Apr 21

cdkx is a specialized command-line interface (CLI) tool designed to bundle assets for AWS Cloud Development Kit (CDK) applications. Primarily utilizing `esbuild` for its high performance, it streamlines the process of preparing CDK-managed code and assets for deployment. The current stable version is 1.0.12. This package aims to provide an efficient bundling solution for TypeScript-based AWS CDK projects, making it easier to manage dependencies and optimize deployment artifacts. Its key differentiator lies in its focused approach to integrating `esbuild` directly into the CDK development workflow, offering a simpler alternative for asset bundling compared to configuring `esbuild` manually or relying on broader build tools. While not an official AWS CDK tool, it integrates with `@aws-cdk/core` to provide a tailored bundling experience for CDK constructs.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to use the `cdkx` CLI to bundle a TypeScript Lambda function, specifying common `esbuild` options and an output directory for CDK assets.

npx cdkx bundle src/lambda/my-function.ts \
  --platform=node \
  --target=es2020 \
  --format=cjs \
  --sourcemap \
  --bundle \
  --out-dir=./cdk.out/assets \
  --external:aws-sdk

console.log("CDK asset bundled successfully to cdk.out/assets");
// In a CDK stack:
// import * as lambda from 'aws-cdk-lib/aws-lambda';
// import * as path from 'path';
// new lambda.Function(this, 'MyLambdaFunction', {
//   runtime: lambda.Runtime.NODEJS_18_X,
//   handler: 'my-function.handler',
//   code: lambda.Code.fromAsset(path.join(__dirname, '../../cdk.out/assets'))
// });

view raw JSON →