Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karma-rollup-preprocessor

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-rollup-preprocessor

Karma preprocessor to bundle ES modules using Rollup

  • 7.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58K
increased by10.44%
Maintainers
1
Weekly downloads
 
Created
Source

karma-rollup-preprocessor

Karma preprocessor to bundle ES modules using Rollup.

Build Status Downloads Version MIT License


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

Happy bundling! heart

Keywords

FAQs

Package last updated on 07 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc