rollup-plugin-json-output
v1.1.0
Published
Convert modules to JSON by serializing their default exports
Readme
rollup-plugin-json-output
A Rollup/Rolldown plugin that converts modules to JSON by serializing their default exports using JSON.stringify.
- ⚡️ Generate dynamic JSON from JavaScript configuration files
- 🔄 Seamless integration with Rollup/Rolldown build process
Requirements
- Node.js >= 25.0.0 or Deno >= 2.5.0
- Rollup >= 2.0.0 or Rolldown
Usage
Install
npm install --save-dev rollup-plugin-json-outputExample
// rollup.config.js
import { jsonOutput } from "rollup-plugin-json-output";
export default [
{
// Main build configuration
input: "src/index.js",
output: {
dir: "dist"
}
}, {
input: "manifest.config.js",
output: {
file: "dist/manifest.json",
},
plugins: [jsonOutput()]
}
];
// manifest.config.js
import packageJson from "./package.json" with { type: "json" };
export default {
manifest_version: 3,
name: "my-extension",
version: packageJson.version
};Options
indent: Specify the indentation of the JSON output. Set tonullfor no indentation.- Type:
string | number | null - Default:
(4 spaces)
- Type:
replacer: Transform or filter values during serialization.- Type:
(key: string, value: unknown) => unknown | (number | string)[] - Default:
undefined
- Type:
respectCompact: Control whether to respect the bundler's minification settings. When enabled,indentis ignored if the bundler setoutput.compact(Rollup) oroutput.minify(Rolldown) totrue.- Type:
boolean - Default:
true
- Type:
License
Copyright © 2025 yetDragon
This project is licensed under the Copyfree Open Innovation License (COIL-1.0). See LICENSE.md for details.
