Skip to main content

@aws-prototyping-sdk/nx-monorepo

Project description

The nx-monorepo package vends a NxMonorepoProject Projen construct that adds NX monorepo support and manages your yarn/npm/pnpm workspaces on your behalf. This construct enables polygot builds (and inter language build dependencies), build caching, dependency visualization and much, much more.

The PDK itself uses the nx-monorepo project itself and is a good reference for seeing how a complex, polygot monorepo can be set up.

To get started simply run the following command in an empty directory:

npx projen new --from aws-prototyping-sdk nx-monorepo

This will boostrap a new Projen monorepo and contain the following in the .projenrc.ts:

import { nx_monorepo } from "aws-prototyping-sdk";

const project = new nx_monorepo.NxMonorepoProject({
  defaultReleaseBranch: "main",
  devDeps: ["aws-prototyping-sdk"],
  name: "my-package",
});

project.synth();

To add new packages to the monorepo, you can simply add them as a child to the monorepo. To demonstrate, lets add a PDK Pipeline TS Project as a child as follows:

import { nx_monorepo } from "aws-prototyping-sdk";

const project = new nx_monorepo.NxMonorepoProject({
  defaultReleaseBranch: "main",
  devDeps: ["aws-prototyping-sdk"],
  name: "my-package",
});

new PDKPipelineTsProject({
  parent: project,
  outdir: "packages/cicd",
  defaultReleaseBranch: "mainline",
  name: "cicd",
  cdkVersion: "2.1.0"
});

project.synth();

Once added, run npx projen from the root directory. You will now notice a new TS package has been created under the packages/cicd path.

Now lets add a python project to the monorepo and add a inter-language build dependency.

import { nx_monorepo } from "aws-prototyping-sdk";
import { PDKPipelineTsProject } from "aws-prototyping-sdk/pipeline";
import { PythonProject } from "projen/lib/python";

const project = new nx_monorepo.NxMonorepoProject({
  defaultReleaseBranch: "main",
  devDeps: ["aws-prototyping-sdk"],
  name: "test",
});

const pipelineProject = new PDKPipelineTsProject({
  parent: project,
  outdir: "packages/cicd",
  defaultReleaseBranch: "mainline",
  name: "cicd",
  cdkVersion: "2.1.0"
});

// Standard Projen projects also work here
const pythonlib = new PythonProject({
  parent: project,
  outdir: "packages/pythonlib",
  authorEmail: "",
  authorName: "",
  moduleName: "pythonlib",
  name: "pythonlib",
  version: "0.0.0"
});

// Pipeline project depends on pythonlib to build first
project.addImplicitDependency(pipelineProject, pythonlib);

project.synth();

Run npx projen from the root directory. You will now notice a new Python package has been created under packages/pythonlib.

To visualize our dependency graph, run the following command from the root directory: npx nx graph.

Now lets test building our project, from the root directory run npx nx run-many --target=build --all. As you can see, the pythonlib was built first followed by the cicd package.

The NxMonorepoProject also manages your yarn/pnpm workspaces for you and synthesizes these into your package.json pnpm-workspace.yml respectively.

For more information on NX commands, refer to this documentation.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_prototyping_sdk.nx_monorepo-0.0.81.tar.gz (69.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file aws_prototyping_sdk.nx_monorepo-0.0.81.tar.gz.

File metadata

File hashes

Hashes for aws_prototyping_sdk.nx_monorepo-0.0.81.tar.gz
Algorithm Hash digest
SHA256 54fce8d6bf0bebf235245e03daf00e31f56d6c3861085bfbea17c5f424439a3d
MD5 da2180099882b2877f44bb0ec4e0c861
BLAKE2b-256 0285e09410e0a7d34bf0e3c52d21d165e5906bf3bb0065789a92b40aaa80292a

See more details on using hashes here.

File details

Details for the file aws_prototyping_sdk.nx_monorepo-0.0.81-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_prototyping_sdk.nx_monorepo-0.0.81-py3-none-any.whl
Algorithm Hash digest
SHA256 eccd1662760bf8f7db1a60ab4fd94763729da5cd6e9c9b3e335027ec785e327a
MD5 c2b8b027764b32a6fa94c0cc82f900b0
BLAKE2b-256 61e7df105a08fe4f1c5ef8241ce4c9a1a696c2fcdf92a975dea8fc71dc29f520

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page