Convert .json files to ES6 modules
JavaScript
Latest commit 8f753fa Dec 15, 2016 @Rich-Harris Rich-Harris -> v2.1.0

README.md

rollup-plugin-json

Convert .json files to ES6 modules:

// import a single property from a JSON file,
// discarding the rest
import { version } from './package.json';
console.log( `running version ${version}` );

// import the whole file as an object
import pkg from './package.json';
console.log( `running version ${pkg.version}` );

Installation

npm install --save-dev rollup-plugin-json

Usage

import { rollup } from 'rollup';
import json from 'rollup-plugin-json';

rollup({
  entry: 'main.js',
  plugins: [
    json({
      // All JSON files will be parsed by default,
      // but you can also specifically include/exclude files
      include: 'node_modules/**',  // Default: undefined
      exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],  // Default: undefined
      preferConst: true, // Default: false
    })
  ]
});

License

MIT