All Projects → evocateur → Pectin

evocateur / Pectin

Licence: isc
Rollup-related tools for incremental transpilation of packages in Lerna-based monorepos

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Pectin

Ts Monorepo
Template for setting up a TypeScript monorepo
Stars: ✭ 459 (+818%)
Mutual labels:  rollup, lerna, monorepo
Sketchmine
Tools to validate, generate and analyse sketch files from web pages
Stars: ✭ 114 (+128%)
Mutual labels:  rollup, lerna, monorepo
Syncpack
Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces
Stars: ✭ 356 (+612%)
Mutual labels:  lerna, cli, monorepo
monoreact
📦 React workspaces implementation
Stars: ✭ 13 (-74%)
Mutual labels:  rollup, monorepo
pacote
A box of goodies, in TypeScript.
Stars: ✭ 14 (-72%)
Mutual labels:  lerna, monorepo
monopacker
A tool for managing builds of monorepo frontend projects with eg. npm- or yarn workspaces, lerna or similar tools into a standalone application - no other tools needed.
Stars: ✭ 17 (-66%)
Mutual labels:  lerna, monorepo
manager
OVHcloud Control Panel
Stars: ✭ 153 (+206%)
Mutual labels:  rollup, lerna
Flopflip
🎚Flip or flop features in your React application in real-time backed by flag provider of your choice 🚦
Stars: ✭ 334 (+568%)
Mutual labels:  rollup, lerna
mono.ts
A minimal example of a typescript mono repo with pre-build support (tests, vscode).
Stars: ✭ 58 (+16%)
Mutual labels:  lerna, monorepo
Entria Fullstack
Monorepo Playground with GraphQL, React, React Native, Relay Modern, TypeScript and Jest
Stars: ✭ 434 (+768%)
Mutual labels:  lerna, monorepo
Ultra Runner
🏃⛰ Ultra fast monorepo script runner and build tool
Stars: ✭ 496 (+892%)
Mutual labels:  lerna, monorepo
Lerna Changelog
📖 PR-based changelog generator with monorepo support
Stars: ✭ 611 (+1122%)
Mutual labels:  lerna, monorepo
ng-mono-repo-starter
Angular Mono Repo Starter
Stars: ✭ 79 (+58%)
Mutual labels:  lerna, monorepo
lerna-terminal
Powerful cli ui for monorepos
Stars: ✭ 25 (-50%)
Mutual labels:  lerna, monorepo
monopack
A JavaScript bundler for node.js monorepo-codebased applications.
Stars: ✭ 52 (+4%)
Mutual labels:  lerna, monorepo
vscode-monorepo-workspace
📦✨Manage monorepos with multi-root workspaces. Supports Lerna, Yarn, Pnpm, Rushjs and recursive package directories.
Stars: ✭ 93 (+86%)
Mutual labels:  lerna, monorepo
Lerna Yarn Workspaces Example
How to build TypeScript mono-repo project with yarn and lerna
Stars: ✭ 787 (+1474%)
Mutual labels:  lerna, monorepo
eslint-import-resolver-lerna
Resolver for Lerna-based projects for eslint-plugin-import
Stars: ✭ 47 (-6%)
Mutual labels:  lerna, monorepo
react-ecommerce
E-commerce monorepo application using NextJs, React, React-native, Design-System and Graphql with Typescript
Stars: ✭ 136 (+172%)
Mutual labels:  lerna, monorepo
Create React Library
⚡CLI for creating reusable react libraries.
Stars: ✭ 4,554 (+9008%)
Mutual labels:  rollup, cli

Pectin

Rollup-related tools for incremental transpilation of packages in Lerna-based monorepos

npm version Build Status

Getting Started

The easiest way to start using Pectin is to install the CLI and run it during an npm lifecycle, such as "prerelease":

npm i -D pectin

In your monorepo's root package.json (aka "manifest"):

{
    "scripts": {
        "clean": "git clean -fdx packages",
        "prerelease": "npm run clean && pectin",
        "release": "lerna publish",
        "lint": "eslint .",
        "pretest": "pectin && npm run lint",
        "test": "jest"
    }
}

Configured this way, you can always ensure your packages have the latest build output whenever anyone executes npm run release or incrementally build recent changes before npm test.

Once installed locally, you can experiment with the CLI via npx:

npx pectin -h

To watch packages and rebuild on source change, pass -w, just like Rollup's CLI:

npx pectin -w

Motivation

One advantage of a Lerna monorepo is that you can reduce the amount of repetition between modules by running all development-related tasks (build, lint, test, and so on) from the root of the repository instead of each package one-by-one. This works fine for tools that are capable of running over many packages simultaneously without breaking a sweat, like jest and eslint.

Running Rollup builds over many different package roots, however, is a much trickier business. Pectin was built to facilitate running Rollup builds for all packages in a monorepo, with special consideration for unique monorepo circumstances such as incremental builds, npm lifecycle behavior, and per-package options.

For example, it isn't always the case that every package in a monorepo actually needs to be rebuilt every time the build is run. Consider running jest --watch in a monorepo with 15 packages, but you're only working on one. The naïve approach finds all the packages and passes all of them to Rollup, which means Rollup builds for every package. Pectin optimizes this by testing the "freshness" of the built output against the source tree and only building when a file in the source tree has a more recent change (a higher mtime, for filesystem wizards).

Pectin's CLI was written to seamlessly wrap rollup. It helps avoid, among other things, Rollup's CLI emitting a warning and exiting non-zero when you pass an empty array (that is, no changes since the last build) to Rollup via the default export of rollup.config.js. Pectin's CLI supports all options supported by Rollup's CLI.

Contributing

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Packages

Customizing Plugins

When calling the pectin CLI, there is no support for adding plugins beyond those already included. However, as pectin is mostly just a fancy wrapper around the rollup CLI, it is possible to generate Rollup config programmatically and simulate the "lazy build" behavior of pectin.

First, create a rollup.config.js in the root of your monorepo:

import * as path from 'path';
import { findConfigs } from '@pectin/api';
import visualizer from 'rollup-plugin-visualizer';

export default findConfigs().then(configs =>
    configs.map(cfg => {
        const {
            // format can be 'cjs', 'esm', or 'umd'
            format,
            // absolute directory from pkg.main,
            // e.g. '<root>/packages/<pkg>/dist'
            dir: outputDir,
        } = cfg.output[0];

        // plugins are assigned per-format, as certain
        // formats require different plugin configuration
        if (format === 'esm') {
            cfg.plugins.push(
                visualizer({
                    filename: path.join(outputDir, 'stats.html'),
                })
            );
        }

        return cfg;
    })
);

Then change any references to pectin in your npm scripts to rollup -c:

{
    "scripts": {
        "build": "rollup -c || echo 'no changed packages to build, probably?'",
        "watch": "rollup -c -w"
    }
}

The caveat highlighted by the || alternation above is that rollup will complain if the array generated by findConfigs() is empty, and exits non-zero. Unless caught by the ||, npm run build would exit with an error.

Ignoring Packages

If you have a package that you do not want Pectin to build, you can add the following to its package.json:

"rollup": {
    "skip": true
}

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].