Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chadhietala/broccoli-rollup
Broccoli Plugin For Rollup
https://github.com/chadhietala/broccoli-rollup
broccoli rollup
Last synced: 14 days ago
JSON representation
Broccoli Plugin For Rollup
- Host: GitHub
- URL: https://github.com/chadhietala/broccoli-rollup
- Owner: chadhietala
- Created: 2015-11-22T20:45:17.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-20T15:34:24.000Z (over 1 year ago)
- Last Synced: 2024-04-13T17:14:50.582Z (7 months ago)
- Topics: broccoli, rollup
- Language: JavaScript
- Size: 498 KB
- Stars: 36
- Watchers: 5
- Forks: 23
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-ember - broccoli-rollup - Broccoli Plugin For "Rollup". (Packages / Broccoli)
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`.