Turborepo

NPM workspaces can manage and run scripts for multiple packages by itself. For example, if we have a workspace and inside that we have multiple packages each with a build script, we can run the command npm run build in the root of the project and npm workspaces will run the build script of each package one by one.

Multijet uses Turborepo to simplify the managment of the monorepo.

Turborepo runs the desired scripts in parallel, and not sequentially. This means that a Multijet project is extremely scalable because the speed of the build is not directly affected by the number of libs or microservices.

The following is the default turbo.json configuration file:

turbo.json
{
    "pipeline": {
        "typecheck": {
            "dependsOn": ["^typecheck"]
        },
        "build": {
            "dependsOn": ["^build", "typecheck"],
            "outputs": ["dist/**"]
        },
        "build:debug": {
            "dependsOn": ["^build:debug", "typecheck"]
        },
        "lint": {},
        "lint:fix": {},
        "start": {
            "dependsOn": ["build"]
        },
        "openapi:generate": {
            "cache": false
        },
        "test": {},
        "clean": {
            "cache": false
        }
    },
    "globalDependencies": ["tsconfig.base.json"]
}

A pipeline is simply a script that runs all npm scripts for every package in every workspace.

For example, if we run turbo run build or simply npm run build in the root of your Multijet project, Turborepo will run the build script in parallel for every package (in this case only microservices have a build script).

You can also specify if a scripts depends on another: for example, the build script depends on the typecheck script so Turborepo will first run typecheck for every package and then build.

Last updated