PackTool

Simplify your monorepo config with an extensible package.json.

You have a monorepo and want to reuse configurations across the different packages. PackTool allows you to implement a composable package.json configuration. Don't repeat code. Align dependencies across packages and simplify the maintenance of your monorepo.

package.json
package.base.json
package.reference.json
{
"name": "my-cool-app",
"version": "1.0.0",
"description": "This is my cool app",
"packtool" :{
"extends": ["package.reference.json"],
}
}

Introduction

Getting started

Managing configurations across different packages within a monorepo can be challenging. Fortunately, packtool offers a solution by allowing you to create a composable package.json configuration. Here are some key points:

  • Reuse Configurations: With packtool, you can avoid duplicating code by defining common configurations in a central place. This makes it easier to maintain consistency across your monorepo.
  • Dependencies Alignment: By using packtool, you can ensure that dependencies are aligned across packages. This helps prevent version conflicts and simplifies the management of dependencies.
  • Simplified Maintenance: With a unified package.json configuration, you’ll spend less time updating individual package.json files. Changes can be made in one place and propagated to all packages.

Quick start

Installation

Let's start by installing the tooling using your favorite package manager:

npm install @packtool/core

This will install the packtool bin with two functions :

  • push : will process the reference files to generate a target package. will extend the base package.json to keep your package.json updated.
  • pull : will update the reference pacakge.base.json from the package.json. This is done after the package.json is update fron example after a npm install to keep it in sync.

OS support! in progress

For achieving the best performance we are using rust binaries. We are currenlty just supporting linux x86_64 binaries but plannig to include more platforms soon.

Initialization

after installation you can run the functions with npx, let's start with pull, as it will create the package.base.json files in the different workspaces if they are not available already:

npx packtool pull

once you have your package.base.json in place you can start extending them. For example let's move our react dependencies to a common file. first create the reference file:

// reference.json
{
  "dependencies": {
    "cross-env": "5.0.5",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "tailwindcss": "^3.4.3"
    }
}

and extend the base file :

// package.base.json
{
  ...
  "packtool": {
    "extends": [
      "../../reference.json"
    ]
  },

}

now when we run the push command , the package.json will be updated according to the reference file, so that all packages in the workspace using this extend will share the same dependencies:

npx packtool push

Getting help

If you have any problem please fill an issue in the github repository.