6.1.0 ā€¢ Published 4 months ago

@rollup/plugin-json v6.1.0

Weekly downloads
579,276
License
MIT
Repository
github
Last release
4 months ago

npm size libera manifesto

@rollup/plugin-json

šŸ£ A Rollup plugin which Converts .json files to ES6 modules.

Requirements

This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.

Install

Using npm:

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

Usage

Create a rollup.config.js configuration file and import the plugin:

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

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [json()]
};

Then call rollup either via the CLI or the API.

With an accompanying file src/index.js, the local package.json file would now be importable as seen below:

// src/index.js
import { readFileSync } from 'fs';

const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
console.log(`running version ${pkg.version}`);

Options

compact

Type: Boolean Default: false

If true, instructs the plugin to ignore indent and generates the smallest code.

exclude

Type: String | Array[...String] Default: null

A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String] Default: null

A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

includeArbitraryNames

Type: Boolean Default: false

If true and namedExports is true, generates a named export for not a valid identifier properties of the JSON object by leveraging the "Arbitrary Module Namespace Identifier Names" feature.

indent

Type: String Default: '\t'

Specifies the indentation for the generated default export.

namedExports

Type: Boolean Default: true

If true, instructs the plugin to generate a named export for every property of the JSON object.

preferConst

Type: Boolean Default: false

If true, instructs the plugin to declare properties as variables, using either var or const. This pertains to tree-shaking.

Meta

CONTRIBUTING

LICENSE (MIT)

formbuilderpkg@monodrom/monodrom@zhengxs-devkit/build@polkadot/devbaxia-builddouyabo-threejs-demo@giveerr/rollpkg@backstage/cli@mediinfo/build@knapsack/rollup-config-starter@uponco/admin@g7fe/g7-scriptsfelix-sum-reactesnext-web-modulesadmin-bro-for-nextnode-lib-dependenciesbappo-scriptsschockydiode-inspr-testdiode-testttdiode-inspr-test-test-testdiode-inspr-testtdiode-testdiode-test-test-diodeinspr-test-diode-testdiode-test-insprinspr-diode-test@outwalk/sablerenderless-svelte.dev@jleeson/toolchain-javascript@jleeson/toolchain-typescriptadmiral_storybooklegal-content-front-web@nuxt/deployreact-createpagesmap-buildsmapbuildtamm-pkg-uivain-cli@ericksatelite/library-templategsmlg-scripts@packmate/uicmtter-lib2goodyuiplanet-widgets@yujinpan/vue-component-packvue3-relaxplusplugin-web-modulesesnext-servers40-scriptscognify-js-test@inspr/diodekd-ui-libskdui-libshlyc-components-web@onereach/step-inputs-common@pega/custom-componentmk-beter-clitq-mui@zlfgege/template@ugikie/component-library@ugikie/ss-component-library@ugikie/inputs@ugikie/notestakla-builder@ooxx87/uidemoplayerlands-data-library@fle.cli/react-buildabc-react-com-test-v23solid-start-vercel-edgecal-scriptsvite-playad4m-executor-test@rakuten-rampage/rampageeditor-test1taro-uilibinbegroad-mono@tarpit/abrahamsharedcomponents-dartdigital@inbegroad-tools/admin@inbegroad-tools/clone@inbegroad-tools/mono-admin@danifoldi/nitropack@surmon-china/abc-factorydecal-components-prova2@azoraqua/react-hooks@equinor/sparql-graphanatoliy-bundlerlib-task-modsenlib-task-toastlibtoastlibtoast-testlibtoasttest-modtoast-lib-task-modsen@haseebanwar/react-package-scripts@raysphase/wizard@service-exchange/buildpc_esignatureuixircus-sdktailwind-react-native
6.1.0

4 months ago

6.0.1

7 months ago

6.0.0

1 year ago

5.0.2

1 year ago

5.0.1

2 years ago

5.0.0

2 years ago

4.1.0

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago