Thomas Reggi's Profile Image

@thomasreggi 🌸

Introducing Cerba

November 2, 2020 (Syndicated From

Cover Image

TLDR: cerba is a command-line tool to generate a npm package from a single file.

I’ve loved the idea of creating small packages, but in practice it’s a huge pain. One tool that has made a tremendous difference in the ecosystem over the past couple of years is lerna. lerna helps people create “monorepos” and maintain, manage, and publish multiple npm modules in one github repo.

Enter cerba (short for Cerberus), what if rather then authoring the code separated and segregated, we create monolithic code that works without thinking about the seperactions. Then, what if we had some way of targeting files and creating modules out of that file.

npx cerba build --main ./src/example.ts

This command will track down all the dependencies used by ./src/example.ts and it will copy all the local files into a new folder ./packages/example, and it will create a package.json file it will also auto-generate the package dependency list by pulling in only the used modules from the root packages. All other “local” files that are referenced by this file will also be copied to this new destination file.

TLDR; cerba let’s you target a file, and build a package from it.

You can also define a define a cerba.json, that looks something like this:

  "packages": [{
    "name": "demo",
    "main": "./src/demo.ts"

The config file lets you define multiple package.json files in one file, just the essentials for what will need to be in the built module.

I’ve had this idea for quite some time now, and I’m happy to get it off the ground and share it with the world. This is really just a proof of concept and in order for it to really work I think it still needs some other key features. If you’re interested in discussing ideas, I’d love to chat! Send me a message or leave a comment!

Checkout the project on github here:

Credit Creative Commons: cerberus by Saeful Muslim from the Noun Project