node package manager

karma-rollup-preprocessor

Karma preprocessor to bundle ES2015 modules using Rollup

Karma preprocessor to bundle ES2015 modules using Rollup.

Build Status Dependency Status Downloads Version 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 --save-dev

Configuration

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

Example

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

// karma.conf.js 
module.exports = function (config) {
    config.set({
 
        files: [
            // watch src files for changes but 
            // don't load them into the browser. 
            { pattern: 'src/**/*.js', included: false },
            'test/**/*.spec.js',
        ],
 
        preprocessors: {
            'src/**/*.js': ['rollup'],
            'test/**/*.spec.js': ['rollup'],
        },
 
        rollupPreprocessor: {
            plugins: [
                require('rollup-plugin-buble')(),
            ],
            format: 'iife',               // helps prevent naming collisions 
            moduleName: '<your_project>', // required for 'iife' format 
            sourceMap: 'inline',          // sensible for testing 
        },
    });
};

Support

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