Chapter 13. Contributing to CDK
CDK construct libraries are typically published as npm packages and can be installed and used in CDK applications using standard package management tools. They provide a convenient way to encapsulate and share reusable infrastructure components, making it easier for developers to provision and manage AWS resources in their CDK applications.
This chapter “zooms out” from a specific CDK project and covers how to package your solutions to share with others.
Anatomy of an npm Library
An npm library typically consists of several parts and functions that contribute to its overall functionality. Libraries are packages published to the npm registry and provide reusable components. Because others will be using this code, it is important that you include all the expected components:
- package.json
-
This is a mandatory file in any npm library and serves as the configuration file for the package. It includes metadata such as the package name, version, description, dependencies, scripts, and other information that defines the package’s behavior and dependencies.
- Source code
-
These are the actual JavaScript or TypeScript source code files that implement the functionality of the library. These source files may be organized in directories or modules, depending on the library’s structure and design.
- Entry point
-
The entry point is the main file that gets executed when the library is imported or required in a Node.js or JavaScript application. It typically defines ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access