rollup-config-pectin

raw JSON →
4.0.4 verified Mon Apr 27 auth: no javascript

A Rollup configuration preset for building tree-shakeable JavaScript libraries using conventional file patterns. Version 4.0.4 requires Node >=8.9 and Rollup >=1.12.0. It simplifies setting up Rollup with Babel and ensures proper main/module exports for ESM and CJS. Differentiators: convention over configuration, zero-config unless custom Babel preset options needed, and explicit support for tree-shaking via peer dependencies. Aimed at library authors who want a minimal Rollup setup without manual config.

error Error: Could not resolve entry module
cause Missing or incorrect 'input' option or no 'src/index.js' file.
fix
Ensure 'src/index.js' exists or specify correct input path via -i flag or options.
error (!) Plugin typescript: @rollup/plugin-typescript: Could not find source file: 'src/index.ts'
cause The configuration expects a JavaScript file (src/index.js) but only TypeScript files exist.
fix
Rename file to 'src/index.js' or configure rollup-config-pectin with an appropriate plugin for TypeScript.
error Error: You must specify 'main' and 'module' in package.json
cause The preset checks for these fields and throws if missing.
fix
Add both 'main' and 'module' fields to package.json.
gotcha The package expects both 'main' and 'module' fields in package.json, otherwise output may be incomplete.
fix Add 'main' and 'module' fields to package.json pointing to your output files.
gotcha If you have a .babelrc, the preset used must accept options (e.g., @babel/preset-env with modules:false), otherwise Rollup's tree-shaking may fail.
fix Ensure your Babel preset configuration is set appropriately (e.g., {modules: false}).
deprecated The package uses the older node:pectin preset for Rollup CLI which may become deprecated in future Rollup versions.
fix Consider using the programmatic API (import default) for future-proofing.
npm install rollup-config-pectin
yarn add rollup-config-pectin
pnpm add rollup-config-pectin

Shows setup: package.json with main/module, Babel config with modules:false, and using rollup-config-pectin via CLI or programmatic API.

// package.json
{
  "main": "dist/index.cjs.js",
  "module": "dist/index.esm.js"
}

// .babelrc (must accept options)
{
  "presets": [
    ["@babel/preset-env", { "modules": false }]
  ]
}

// rollup.config.js (if using programmatic API)
import pectin from 'rollup-config-pectin';
export default pectin({
  input: 'src/index.js',
  output: {
    dir: 'dist',
    format: ['cjs', 'es']
  }
});

// Or via CLI:
// rollup -c node:pectin -i src/index.js