JSPM

  • Created
  • Published
  • Downloads 452469
  • Score
    100M100P100Q43731F
  • License MIT

Convert CommonJS modules to ES2015

Package Exports

  • rollup-plugin-commonjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rollup-plugin-commonjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rollup-plugin-commonjs

Convert CommonJS modules to ES6, so they can be included in a Rollup bundle

Installation

npm install --save-dev rollup-plugin-commonjs

Usage

Typically, you would use this plugin alongside rollup-plugin-npm, so that you could bundle your CommonJS dependencies in node_modules.

import { rollup } from 'rollup';
import commonjs from 'rollup-plugin-commonjs';
import npm from 'rollup-plugin-npm';

rollup({
  entry: 'main.js',
  plugins: [
    npm({
      jsnext: true,
      main: true
    }),

    // non-CommonJS modules will be ignored, but you can also
    // specifically include/exclude files
    commonjs({
      include: 'node_modules/**',
      exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],
      
      // add this if you want to generate sourcemaps later
      sourceMap: true
    })
  ]
}).then(...)

License

MIT