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

@rollup/plugin-json

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-json

Convert .json files to ES6 modules

  • 5.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5M
decreased by-6.32%
Maintainers
4
Weekly downloads
 
Created

What is @rollup/plugin-json?

The @rollup/plugin-json npm package allows users to import JSON files as modules in their Rollup bundles. It converts JSON files into ES6 modules, making it possible to include JSON data in the bundle as if they were regular JavaScript modules.

What are @rollup/plugin-json's main functionalities?

Import JSON files as modules

This feature allows you to import JSON files directly into your JavaScript code. The JSON data is parsed and transformed into an ES6 module, which can then be used like any other imported module.

import config from './config.json';
console.log(config);

Customize indentation

This feature allows you to specify the indentation for the generated default export, giving you control over the formatting of the output.

import json from '@rollup/plugin-json';

export default {
  plugins: [
    json({
      indent: '  '
    })
  ]
};

Filter which JSON files to include

This feature allows you to use a filter function to determine which JSON files should be processed by the plugin. This is useful when you want to include only certain JSON files based on a pattern or condition.

import json from '@rollup/plugin-json';
import { createFilter } from '@rollup/pluginutils';

const filter = createFilter('**/config/*.json');

export default {
  plugins: [
    json({
      include: filter
    })
  ]
};

Exclude JSON files

This feature allows you to exclude certain JSON files from being processed by the plugin. For example, you might want to exclude JSON files from the 'node_modules' directory.

import json from '@rollup/plugin-json';

export default {
  plugins: [
    json({
      exclude: ['node_modules/**']
    })
  ]
};

Other packages similar to @rollup/plugin-json

Keywords

FAQs

Package last updated on 21 Oct 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