{"id":15565,"library":"cdkx","title":"CDK Bundler","description":"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.","status":"active","version":"1.0.12","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install cdkx","lang":"bash","label":"npm"},{"cmd":"yarn add cdkx","lang":"bash","label":"yarn"},{"cmd":"pnpm add cdkx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core bundler engine for optimizing CDK assets.","package":"esbuild"},{"reason":"Used for compiling TypeScript source files before bundling. A dev dependency for most projects, but listed here as a primary tool.","package":"typescript"},{"reason":"Provides core AWS CDK constructs and types that the bundler interacts with.","package":"@aws-cdk/core"}],"imports":[{"note":"Primary interaction is via the `cdkx` CLI command. Direct programmatic imports are not the common pattern for this package.","wrong":"import { cdkx } from 'cdkx'","symbol":"cdkx","correct":"npx cdkx bundle [options]"},{"note":"The `bundle` command is the main function exposed by the CLI for processing assets.","symbol":"bundle","correct":"cdkx bundle src/my-lambda.ts --out-dir dist"},{"note":"While `cdkx` has an `index.js` as its `main` entry, its primary intended use is through the CLI. A direct programmatic Node.js API is not explicitly documented for public consumption in the provided context, but a library could potentially import internal functions.","symbol":"Node.js API (hypothetical)","correct":"import { bundleAsset } from 'cdkx';\n// Usage example (API might not be officially exposed or documented for direct use)"}],"quickstart":{"code":"npx cdkx bundle src/lambda/my-function.ts \\\n  --platform=node \\\n  --target=es2020 \\\n  --format=cjs \\\n  --sourcemap \\\n  --bundle \\\n  --out-dir=./cdk.out/assets \\\n  --external:aws-sdk\n\nconsole.log(\"CDK asset bundled successfully to cdk.out/assets\");\n// In a CDK stack:\n// import * as lambda from 'aws-cdk-lib/aws-lambda';\n// import * as path from 'path';\n// new lambda.Function(this, 'MyLambdaFunction', {\n//   runtime: lambda.Runtime.NODEJS_18_X,\n//   handler: 'my-function.handler',\n//   code: lambda.Code.fromAsset(path.join(__dirname, '../../cdk.out/assets'))\n// });","lang":"typescript","description":"Demonstrates how to use the `cdkx` CLI to bundle a TypeScript Lambda function, specifying common `esbuild` options and an output directory for CDK assets."},"warnings":[{"fix":"Before `npm publish`, update `package.json`: `\"private\": false`. After publishing, revert to `\"private\": true` if it's an internal package within a monorepo managed by `lerna`.","message":"When publishing your package, ensure `private` is set to `false` in `package.json`. If `cdkx` is part of a larger `lerna` monorepo where it's typically marked `private` during development, this step is critical before running `npm publish`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consult `esbuild` documentation for advanced features. If `cdkx` doesn't provide a passthrough or specific option, consider using `esbuild` directly for those assets or contributing to `cdkx`.","message":"The `cdkx` tool wraps `esbuild`. For advanced `esbuild` configurations not directly exposed by `cdkx` options, you might need to use `esbuild` directly or contribute features to `cdkx`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Before publishing, set `\"private\": false` in `package.json`. Remember to revert it if `cdkx` is part of a monorepo that requires it to be private during local development.","cause":"Attempting to `npm publish` a package with `\"private\": true` in its `package.json`.","error":"Error: This package is private and cannot be published. (code EPRIVATE)"},{"fix":"Ensure `esbuild` is listed in your project's `dependencies` and run `npm install` or `yarn install`.","cause":"The `esbuild` dependency is not correctly installed, or the Node.js environment cannot locate it.","error":"Cannot find module 'esbuild'"}],"ecosystem":"npm"}