# rollup-plugin-json

> Convert .json files to ES6 modules:

Latest version **4.0.0** (published 2019-03-18) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install rollup-plugin-json
pnpm add rollup-plugin-json
yarn add rollup-plugin-json
bun add rollup-plugin-json
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2019-03-18 |
| First published | 2015-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/rollup-plugin-json) |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 126 |
| Maintainers | guybedford, lukastaegert, rich_harris |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-json
- Repository: https://github.com/rollup/rollup-plugin-json
- Homepage: https://github.com/rollup/rollup-plugin-json#readme
- Issues: https://github.com/rollup/rollup-plugin-json/issues
- npm.io page: https://npm.io/package/rollup-plugin-json

## Dependencies (1)

- [rollup-pluginutils](https://npm.io/package/rollup-pluginutils.md) ^2.5.0

## Recent versions

- 4.0.0 (latest) — 2019-03-18
- 3.1.0 — 2018-09-13
- 3.0.0 — 2018-05-11
- 2.3.1 — 2018-05-11
- 2.3.0 — 2017-06-03
- 2.2.0 — 2017-06-03
- 2.1.1 — 2017-04-09
- 2.1.0 — 2016-12-15
- 2.0.2 — 2016-09-07
- 2.0.1 — 2016-06-23
- 2.0.0 — 2015-11-05
- 1.0.0 — 2015-10-25

## README

# rollup-plugin-json

Convert .json files to ES6 modules:

```js
// 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

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


## Usage

```js
// rollup.config.js
import json from 'rollup-plugin-json';

export default {
  input: 'src/main.js',
  output: {
    file: 'dist/bundle.js',
    format: 'iife'
  },

  plugins: [
    json({
      // All JSON files will be parsed by default,
      // but you can also specifically include/exclude files
      include: 'node_modules/**',
      exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],

      // for tree-shaking, properties will be declared as
      // variables, using either `var` or `const`
      preferConst: true, // Default: false

      // specify indentation for the generated default export —
      // defaults to '\t'
      indent: '  ',

      // ignores indent and generates the smallest code
      compact: true, // Default: false

      // generate a named export for every property of the JSON object
      namedExports: true // Default: true
    })
  ]
};
```


## License

MIT

---
_Source: https://npm.io/package/rollup-plugin-json · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
