# broccoli-rollup

> A broccoli plugin that uses rollup.js on its input

Latest version **5.0.0** (published 2021-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-rollup
pnpm add broccoli-rollup
yarn add broccoli-rollup
bun add broccoli-rollup
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2021-05-25 |
| First published | 2015-12-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.0 |
| Dependencies | 9 |
| Unpacked size | 41.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 37 |
| Author | Chad Hietala |
| Maintainers | krisselden, rwjblue, chadhietala, stefanpenner |
| Keywords | broccoli, broccoli plugin, rollup |

## Links

- npm: https://www.npmjs.com/package/broccoli-rollup
- Repository: https://github.com/chadhietala/broccoli-rollup
- Homepage: https://github.com/chadhietala/broccoli-rollup#readme
- Issues: https://github.com/chadhietala/broccoli-rollup/issues
- npm.io page: https://npm.io/package/broccoli-rollup

## Dependencies (9)

- [rollup](https://npm.io/package/rollup.md) ^2.50.0
- [walk-sync](https://npm.io/package/walk-sync.md) ^2.2.0
- [heimdalljs](https://npm.io/package/heimdalljs.md) ^0.2.6
- [fs-tree-diff](https://npm.io/package/fs-tree-diff.md) ^2.0.1
- [broccoli-plugin](https://npm.io/package/broccoli-plugin.md) ^4.0.7
- [symlink-or-copy](https://npm.io/package/symlink-or-copy.md) ^1.2.0
- [node-modules-path](https://npm.io/package/node-modules-path.md) ^1.0.1
- [rollup-pluginutils](https://npm.io/package/rollup-pluginutils.md) ^2.8.1
- [@types/broccoli-plugin](https://npm.io/package/@types/broccoli-plugin.md) ^3.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2021-05-25
- 4.1.1 — 2019-06-06
- 4.1.0 — 2019-05-16
- 4.0.0 — 2019-05-15
- 3.0.0 — 2019-05-15
- 2.1.1 — 2018-06-08
- 2.1.0 — 2018-03-23
- 2.0.0 — 2017-11-17
- 1.3.0 — 2017-05-02
- 1.2.0 — 2017-04-03
- 1.1.3 — 2017-03-01
- 1.1.2 — 2017-03-01
- 1.1.1 — 2017-03-01
- 1.1.0 — 2017-02-06
- 1.0.3 — 2016-08-31
- … 6 more at https://npm.io/package/broccoli-rollup/versions

## README

# `broccoli-rollup`

[![Build Status](https://travis-ci.org/chadhietala/broccoli-rollup.svg?branch=master)](https://travis-ci.org/chadhietala/broccoli-rollup)

A [broccoli](https://broccoli.build/) plugin that uses [rollup.js](https://rollupjs.org/) on its input.

## Usage

### Basic

```js
// Brocfile.js
import rollup from 'broccoli-rollup';

export default () =>
  rollup('lib', {
    // nodeModulesPath: string Defaults to process.cwd()
    rollup: {
      input: 'index.js',
      output: {
        file: 'bundle.js',
        format: 'es',
      },
    },
  });
```

### Code Splitting

```js
// Brocfile.js
import rollup from 'broccoli-rollup';

export default () =>
  rollup('lib', {
    // nodeModulesPath: string Defaults to process.cwd()
    rollup: {
      input: 'index.js',
      output: {
        dir: 'chunks',
        format: 'es',
      },
    },
  });
```

### Multiple Output

```js
// Brocfile.js
import rollup from 'broccoli-rollup';

export default () =>
  rollup('lib', {
    // nodeModulesPath: string Defaults to process.cwd()
    rollup: {
      input: 'index.js',
      output: [
        {
          file: 'my-lib.amd.js',
          format: 'amd',
        },
        {
          file: 'my-lib.iife.js',
          name: 'MyLib',
          format: 'iife',
        },
      ],
    },
  });
```

## Notes and Caveats

Broccoli is designed around immutable input and although rollup does expose enough
in the build output for us to write it to disk, this doesn't work with the `onwrite` plugin hook
and requires a significant amount of code to get feature parity with rollup's
`buildOutput.write(outputOptions)`.

We use the following build flow to achieve compatibility and feature parity with rollup's cli
while still adhering to broccoli's immutable input constraints.

1. sync `node.inputPaths[0]` to `${node.cachePath}/build`
2. symlink `options.nodeModulesPath` to `${node.cachePath}/node_modules`
3. change the working directory to `${node.cachePath}/build` (rollup doesn't allow this to be passed in and plugins may also the use cwd)
4. run rollup
5. restore the working directory
6. sync `${node.cachePath}/build` to `node.outputPath` for all files that are different from the input.

If you have any plugins that require hard-coded paths into `node_modules`,
please note that `node_modules` is symlinked above the build path.

So instead of doing `node_modules/x` you need to do `../node_modules/x`.

---
_Source: https://npm.io/package/broccoli-rollup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
