jsii and package.json

The CLI commands in this module assume you are in the multi-region-s3-crr-kms-cmk-target directory (root of the project)

Install the jsii and pacmac libraries we will be using

These libraries are what allow us to bundle our constructs into artifacts for all supported languages.

npm install --save-dev jsii jsii-pacmak

Update our package.json

We need to modify our package.json to:

  • update our build, watch scripts to use jsii
  • add a package script
  • add some additional fields for author, repository, and license to the construct to use jsii/pacmak
  • add our jsii targets (it produces TypeScript artifacts by default, and in this case we add Python as an example)
  "name": "multi-region-s3-crr-kms-cmk-target",
  "version": "0.1.0",
  "main": "lib/index.js",
  "types": "lib/index.d.ts",
  "scripts": {
    "build": "jsii",
    "watch": "jsii -w",
    "package": "jsii-pacmak",
    "test": "jest"
  "author": {
    "name": "NAME",
    "email": "EMAIL",
    "url": "URL"
  "repository": {
    "url": "https://github.com/OWNER/REPO.git",
    "type": "git"
  "license": "MIT",
  "jsii": {
    "outdir": "dist",
    "targets": {
      "python": {
        "distName": "mycorp.mypackage",
        "module": "mycorp.mypackage"
  "devDependencies": {

We also need to add the constructs library to our peerDependencies:

  "peerDependencies": {
    "@aws-cdk/core": "1.51.0",
    "constructs": "^3.0.2"

Move our TypeScript config file

jsii will generate it’s own TypeScript config so we can move the existing one out of the way:

mv tsconfig.json tsconfig.json.original

Remove our sample tests

To ensure the build process works we will remove the sample tests as they refer to resources we have removed from the construct:

rm test/*.ts