{"id":21497,"library":"karma-rollup","title":"karma-rollup","description":"Karma preprocessor that bundles ES2015 modules using Rollup for testing. Version 1.0.1 is the latest stable release (as of 2023+). Designed for use with Karma test runner, it integrates Rollup as a preprocessor to transpile and bundle ES module imports/exports into a single file per test file. Supports Rollup plugins (e.g., Bublé, Babel), custom preprocessors, watch mode with caching, and sourcemaps. Differentiators: lightweight compared to Webpack-based preprocessors, leverages Rollup's tree-shaking and fast bundling. Requires Rollup >=1.0.0 as a peer dependency.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/tao-zeng/karma-rollup","tags":["javascript","es2015","karma","modules","import","export","plugin","preprocessor","rollup"],"install":[{"cmd":"npm install karma-rollup","lang":"bash","label":"npm"},{"cmd":"yarn add karma-rollup","lang":"bash","label":"yarn"},{"cmd":"pnpm add karma-rollup","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: Rollup >=1.0.0 must be installed separately to function.","package":"rollup","optional":false},{"reason":"Peer dependency: Karma is required to run the preprocessor; typically already installed in test projects.","package":"karma","optional":false}],"imports":[{"note":"This package is a Karma plugin, not a direct import. It's loaded via Karma's plugin system (plugins: ['karma-*']).","wrong":"const rollupPreprocessor = require('karma-rollup')","symbol":"rollupPreprocessor","correct":"// Configure in karma.conf.js – no import needed"},{"note":"Custom preprocessors are defined inside karma.conf.js per Karma documentation; not exported by this package.","wrong":"const customPreprocessors = require('karma-rollup').customPreprocessors","symbol":"customPreprocessors","correct":"// Configure in karma.conf.js – no import needed"},{"note":"Always install as a dev dependency; it's only used during testing.","wrong":"npm install karma-rollup","symbol":"karma-rollup","correct":"npm install karma-rollup --save-dev"}],"quickstart":{"code":"// karma.conf.js\nmodule.exports = function(config) {\n  config.set({\n    basePath: '',\n    frameworks: ['jasmine'],\n    files: [\n      'test/**/*.spec.js'\n    ],\n    plugins: [\n      'karma-jasmine',\n      'karma-chrome-launcher',\n      'karma-rollup'\n    ],\n    preprocessors: {\n      'test/**/*.spec.js': ['rollup']\n    },\n    rollupPreprocessor: {\n      options: {\n        plugins: [require('rollup-plugin-buble')()],\n        output: {\n          format: 'iife',\n          name: 'MyProject',\n          sourcemap: 'inline'\n        }\n      }\n    },\n    browsers: ['ChromeHeadless'],\n    reporters: ['progress'],\n    port: 9876,\n    colors: true,\n    logLevel: config.LOG_INFO,\n    autoWatch: true,\n    singleRun: false,\n    concurrency: Infinity\n  });\n}","lang":"javascript","description":"Basic Karma configuration using karma-rollup preprocessor with Rollup and Bublé for ES2015 transpilation, outputting in IIFE format with inline sourcemaps."},"warnings":[{"fix":"Remove 'input' from options; the input file is determined by Karma's files and preprocessors.","message":"'input' property is handled automatically by karma-rollup; do not set it in rollupPreprocessor.options.","severity":"gotcha","affected_versions":"*"},{"fix":"Update karma-rollup or downgrade Rollup to >=1.0.0 <2.0.0; or test with Rollup 2.0 and adjust output config accordingly.","message":"Rollup 2.0+ changed the output format structure; older karma-rollup versions may not support Rollup >=2. Check peer dep: rollup >=1.0.0 (but may work with 2.x).","severity":"gotcha","affected_versions":"<=1.0.0"},{"fix":"Set the config key as 'rollupPreprocessor' (not 'rollup') in karma.conf.js.","message":"Using 'rollupPreprocessor' configuration, not 'rollup' – the key must be exactly 'rollupPreprocessor'.","severity":"gotcha","affected_versions":"*"},{"fix":"Add 'output.name: 'YourProject'' to rollupPreprocessor.options.","message":"Missing 'name' in output for 'iife' format will cause Rollup error: 'You must supply output.name for IIFE format'.","severity":"gotcha","affected_versions":"*"},{"fix":"Add 'karma-rollup' to config.plugins or use the wildcard pattern 'karma-*'.","message":"If not using default plugins array, ensure 'karma-rollup' is included in the plugins list (or 'karma-*').","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install karma-rollup --save-dev' and ensure plugins includes 'karma-*' or 'karma-rollup'.","cause":"karma-rollup is not installed or not listed in plugins.","error":"Error: Cannot find module 'karma-rollup'"},{"fix":"Add property 'output.name: 'MyProject'' to rollupPreprocessor.options.","cause":"IIFE output format requires a name to avoid global scope collision.","error":"RollupError: You must supply output.name for IIFE format"},{"fix":"Run 'npm install karma-jasmine --save-dev' and add 'jasmine' to frameworks array.","cause":"Karma Jasmine framework not installed.","error":"Error: No provider for \"framework:jasmine\"! (Resolving: framework:jasmine)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}