# karma-rollup-preprocessor

> Karma preprocessor to bundle ES modules using Rollup

Latest version **7.0.8** (published 2022-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install karma-rollup-preprocessor
pnpm add karma-rollup-preprocessor
yarn add karma-rollup-preprocessor
bun add karma-rollup-preprocessor
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.0.8 |
| Published | 2022-02-07 |
| First published | 2015-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/karma-rollup-preprocessor) |
| Module format | CommonJS |
| Node | >= 8.0.0 |
| Dependencies | 2 |
| Unpacked size | 23.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 74 |
| Author | Julian Lloyd |
| Maintainers | jlmakes |
| Keywords | es, es2015, karma, modules, import, export, plugin, preprocessor, karma-preprocessor, karma-plugin, karma-rollup, rollup |

## Links

- npm: https://www.npmjs.com/package/karma-rollup-preprocessor
- Repository: https://github.com/jlmakes/karma-rollup-preprocessor
- Issues: https://github.com/jlmakes/karma-rollup-preprocessor/issues
- npm.io page: https://npm.io/package/karma-rollup-preprocessor

## Dependencies (2)

- [chokidar](https://npm.io/package/chokidar.md) ^3.3.1
- [debounce](https://npm.io/package/debounce.md) ^1.2.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 7.0.8 (latest) — 2022-02-07
- 7.0.0-rc.2 (next) — 2019-01-16
- 7.0.7 — 2021-03-14
- 7.0.6 — 2021-02-25
- 7.0.5 — 2020-03-24
- 7.0.4 — 2020-03-23
- 7.0.3 — 2020-01-17
- 7.0.2 — 2019-07-21
- 7.0.1 — 2019-07-21
- 7.0.0 — 2019-02-06
- 7.0.0-rc.1 — 2019-01-12
- 6.1.2 — 2019-01-02
- 6.1.1 — 2018-11-29
- 6.1.0 — 2018-10-17
- 6.0.1 — 2018-08-14
- … 20 more at https://npm.io/package/karma-rollup-preprocessor/versions

## README

# `karma-rollup-preprocessor`

Karma preprocessor to bundle ES modules using Rollup.

<p>
	<a href="https://travis-ci.org/jlmakes/karma-rollup-preprocessor">
		<img src="https://img.shields.io/travis/jlmakes/karma-rollup-preprocessor?color=black&style=for-the-badge" alt="Build Status">
	</a>
	<a href="https://www.npmjs.com/package/karma-rollup-preprocessor">
		<img src="https://img.shields.io/npm/dm/karma-rollup-preprocessor?color=black&style=for-the-badge" alt="Downloads">
	</a>
	<a href="https://www.npmjs.com/package/karma-rollup-preprocessor">
		<img src="https://img.shields.io/npm/v/karma-rollup-preprocessor?color=black&style=for-the-badge" alt="Version">
	</a>
	<a href="https://opensource.org/licenses/MIT">
		<img src="https://img.shields.io/badge/license-MIT-blue?color=black&style=for-the-badge" alt="MIT License">
	</a>
</p>

<br>

## Installation

```bash
npm install karma-rollup-preprocessor
```

<br>

## Configuration

All the options detailed in the [Rollup Documentation](https://github.com/rollup/rollup/wiki/JavaScript-API) can be passed to `rollupPreprocessor`.

### Standard

Below is a well-founded recommendation using the [Bublé](https://buble.surge.sh) ES2015 transpiler:

```js
// karma.conf.js
module.exports = function (config) {
	config.set({
		files: [
			/**
			 * Make sure to disable Karma’s file watcher
			 * because the preprocessor will use its own.
			 */
			{ pattern: 'test/**/*.spec.js', watched: false },
		],

		preprocessors: {
			'test/**/*.spec.js': ['rollup'],
		},

		rollupPreprocessor: {
			/**
			 * This is just a normal Rollup config object,
			 * except that `input` is handled for you.
			 */
			plugins: [require('rollup-plugin-buble')()],
			output: {
				format: 'iife', // Helps prevent naming collisions.
				name: '<your_project>', // Required for 'iife' format.
				sourcemap: 'inline', // Sensible for testing.
			},
		},
	})
}
```

<br>

### Configured Preprocessors

Below shows an example where [configured preprocessors](http://karma-runner.github.io/1.0/config/preprocessors.html) can be very helpful:

```js
// karma.conf.js
module.exports = function (config) {
	config.set({
		files: [{ pattern: 'test/**/*.spec.js', watched: false }],

		preprocessors: {
			'test/buble/**/*.spec.js': ['rollup'],
			'test/babel/**/*.spec.js': ['rollupBabel'],
		},

		rollupPreprocessor: {
			plugins: [require('rollup-plugin-buble')()],
			output: {
				format: 'iife',
				name: '<your_project>',
				sourcemap: 'inline',
			},
		},

		customPreprocessors: {
			/**
			 * Clones the base preprocessor, but overwrites
			 * its options with those defined below...
			 */
			rollupBabel: {
				base: 'rollup',
				options: {
					// In this case, to use a different transpiler:
					plugins: [require('rollup-plugin-babel')()],
				},
			},
		},
	})
}
```

Happy bundling! ![heart](http://i.imgur.com/oXJmdtz.gif)

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