rollup-presets

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

An opinionated, production-ready Rollup preset collection for building TypeScript libraries and applications. Current version 0.0.27 (early stage, frequent releases). Provides automatic multi-format (ESM/CJS) builds, TypeScript declaration generation, path alias resolution from tsconfig.json, and a four-stage plugin system (pre, transform, post) for extensibility. Differentiators: minimal configuration via package.json exports, built-in esbuild for speed, and opinionated defaults that reduce boilerplate versus raw Rollup setup.

error Error: No such module 'rollup-presets'
cause Package not installed or incorrect import path.
fix
Run: npm install rollup-presets --save-dev. Then verify import path: 'rollup-presets' (not 'rollup/presets').
error TypeError: Cannot read properties of undefined (reading 'plugin')
cause Trying to use libraryPreset without a package.json that has exports or standard fields.
fix
Ensure your package.json includes an 'exports' field like: {"exports": {".": {"import": "./dist/esm/index.js", "require": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts", "source": "./src/index.ts"}}}
error SyntaxError: Cannot use import statement outside a module
cause Running in a CommonJS environment while rollup-presets is ESM-only.
fix
Change your rollup.config.js to .mjs extension or use dynamic import: const { libraryPreset } = await import('rollup-presets');
gotcha Package.json exports are required for libraryPreset to resolve bundle paths correctly; standard fields (main, module, types) are also supported but exports is recommended.
fix Add an 'exports' field or standard fields to your package.json defining the entry points (import, require, types, source).
breaking Version 0.x may introduce breaking changes without semver major bumps; minor versions can change API.
fix Pin to a specific version and test upgrades carefully. Consider using lockfiles.
gotcha The package is ESM-only; CommonJS require() will throw an error.
fix Use dynamic import: const { libraryPreset } = await import('rollup-presets'); or set your project to ESM (type: 'module' in package.json).
gotcha If preserveModules is true, the output directory structure mirrors the source; this can lead to deep nested paths.
fix Set preserveModules: false to flatten output, or ensure your consuming app handles nested imports.
npm install rollup-presets
yarn add rollup-presets
pnpm add rollup-presets

Minimal Rollup config using libraryPreset to build a TypeScript library with ESM and CJS formats.

import { libraryPreset } from 'rollup-presets';

export default libraryPreset();