🌜
🌞
karma-rollup-preprocessor

karma-rollup-preprocessor

v7.0.8

Karma preprocessor to bundle ES modules using Rollup

npm install karma-rollup-preprocessor

README

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

Release Notes

7.0.7
Published on March 14, 2021

Fixed

  • Source map file paths. @ntkme #69 #71
  • File path errors on Windows. @spectras #65 #66
  • Ignore rollup facade modules beginning with a null byte. @Lalem001 #62
  • Ensure original file path is used for processing #56
  • Silence Rollup warnings due to invalid output options #60
2.0.2
By Klaas Cuvelier • Published on May 13, 2016

Minor fixes:

  • #5
  • #7
  • #9
2.0.0
By Klaas Cuvelier • Published on December 14, 2015

Separate rollup and bundle options

General

License
MIT
Typescript Types
None found
Tree-shakeable
No

Popularity

GitHub Stargazers
76
Community Interest
137
Number of Forks
27

Maintenance

Commits
10/219/2201
Last Commit
Feb 7, 2022
Open Issues
3
Closed Issues
33
Open Pull Requests
0
Closed Pull Requests
8

Versions

Versions Released
10/219/2201
Latest Version Released
Current Tags
latest7.0.8
next7.0.0-rc.2

Contributors

jlmakes
jlmakes
Commits: 175
klaascuvelier
klaascuvelier
Commits: 21
lephyrus
lephyrus
Commits: 3
brianmhunt
brianmhunt
Commits: 2
Lalem001
Lalem001
Commits: 2
mjeanroy
mjeanroy
Commits: 2
ntkme
ntkme
Commits: 2
MaartenMortier
MaartenMortier
Commits: 1
FezVrasta
FezVrasta
Commits: 1
CrowdHailer
CrowdHailer
Commits: 1
silenceisgolden
silenceisgolden
Commits: 1
OverZealous
OverZealous
Commits: 1
vdclouis
vdclouis
Commits: 1
matgis
matgis
Commits: 1
mario-d-s
mario-d-s
Commits: 1