Skip to main content

Rollup

Rollup is the de-facto library bundler, offered as a peer to tsup and esbuild. The preset produces unbundled, per-file ESM + CJS output with .d.ts declarations — the same shape as the tsup preset — and leaves every dependency external so the published library stays thin.

Usage

Re-export the default config:

// rollup.config.mjs
export { default } from '@rtorcato/repo-tooling/rollup'

…or customize the entry point:

// rollup.config.mjs
import { getConfig } from '@rtorcato/repo-tooling/rollup'

export default getConfig({ input: 'src/main.ts' })

Then wire it into package.json:

{
"scripts": {
"build": "rollup -c",
"build:watch": "rollup -c --watch"
}
}

setup --preset library scaffolds this for you when you pick Rollup, and npx @rtorcato/repo-tooling fix rollup drops the rollup.config.mjs into an existing project.

Peer dependencies

The preset expects these in your devDependencies (added automatically by setup/fix):

  • rollup
  • @rollup/plugin-typescript
  • tslib

API

getConfig(options?)

Returns an array of two Rollup configs (ESM + CJS). Declarations are emitted once, from the ESM pass.

OptionDefaultMeaning
inputsrc/index.tsLibrary entry point
outDirdistOutput directory for JS + declarations
sourcemaptrueEmit sourcemaps
externalevery bare importWhich ids to leave external
tsconfig./tsconfig.jsontsconfig for @rollup/plugin-typescript