karma-rollup-preprocessor
Karma preprocessor to bundle ES2015 modules using Rollup
Last updated 4 months ago by jlmakes .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install karma-rollup-preprocessor 
SYNC missed versions from official npm registry.


Karma + Rollup

Karma preprocessor to bundle ES2015 modules using Rollup.

Build Status Dependency Status Downloads Version MIT License


Features

  • Rebundles your files when watched dependencies change
  • Caches bundle output for improved performance
  • Maintained with heart by @jlmakes

Installation

npm install karma-rollup-preprocessor

Configuration

All the options detailed in the Rollup Documentation can be passed to rollupPreprocessor.

Standard

Below is a well-founded recommendation using the Bublé ES2015 transpiler:

// 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.
			},
		},
	})
}

Configured Preprocessors

Below shows an example where configured preprocessors can be very helpful:

// 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')()],
				},
			},
		},
	})
}

Support

Supports all Rollup plug-ins, and works on Node 8 and up. Happy bundling!

Current Tags

  • 7.0.2                                ...           latest (4 months ago)
  • 7.0.0-rc.2                                ...           next (10 months ago)

29 Versions

  • 7.0.2                                ...           4 months ago
  • 7.0.1                                ...           4 months ago
  • 7.0.0                                ...           9 months ago
  • 7.0.0-rc.2                                ...           10 months ago
  • 7.0.0-rc.1                                ...           10 months ago
  • 6.1.2                                ...           10 months ago
  • 6.1.1                                ...           a year ago
  • 6.1.0                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.3                                ...           2 years ago
  • 5.0.2                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.4                                ...           2 years ago
  • 4.0.3                                ...           2 years ago
  • 4.0.2                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 4.0.0                                ...           3 years ago
  • 3.0.3                                ...           3 years ago
  • 3.0.2                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           4 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.0                                ...           4 years ago

Copyright 2014 - 2016 © taobao.org |