Registry / devops / esbuild-plugin-json-cleaner

esbuild-plugin-json-cleaner

JSON →
library0.1.3jsnpmunverified

An esbuild plugin for cleaning JSON files during the build process. It supports removing top-level tags (like schema references), minifying output, and customizing indentation. Current version is 0.1.3, released as an early-stage tool with peer dependency on esbuild ^0.27.2. It differentiates by being a minimal, focused plugin for JSON cleanup in esbuild builds, with TypeScript support and dual ESM/CJS exports. Suitable for workflows that need to strip metadata from JSON files before bundling.

npm install esbuild-plugin-json-cleaner
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-JSO
E
esbuild-plugin-json-cleaner
devopsjavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import JSONCleanerPlugin from 'esbuild-plugin-json-cleaner'
const JSONCleanerPlugin = require('esbuild-plugin-json-cleaner')
Default export only; CommonJS require results in undefined.

Shows how to configure the plugin to remove 'schema' and specific tags from a JSON file, with custom indentation.

import esbuild from 'esbuild'; import JSONCleanerPlugin from 'esbuild-plugin-json-cleaner'; await esbuild.build({ outdir: 'dist', plugins: [ JSONCleanerPlugin({ src: 'src/data.json', out: 'data.json', removeSchema: true, removeTags: ['project', 'revision'], minify: false, space: 2, }), ], });
Debug
Known issues
gotchaDefault export only; CommonJS require returns undefined.
fix
Use import syntax or use the default export via require('esbuild-plugin-json-cleaner').default.
affects: >=0.1.0
breakingPeer dependency esbuild ^0.27.2 required; older versions incompatible.
fix
Update esbuild to version ^0.27.2 or later.
affects: >=0.1.0
gotchaNode.js >=24 required; fails on older versions.
fix
Use Node.js version 24 or higher.
affects: >=0.1.0
gotchaPlugin processes only the specified src file; no glob or directory support.
fix
Use multiple plugin instances for multiple files or manually iterate.
affects: >=0.1.0
gotcharemoveTags removes top-level keys only; nested keys are unaffected.
fix
Specify full top-level keys to remove.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: JSONCleanerPlugin is not a function
Using CommonJS require and calling it as a function, but default export requires import or .default
fix
Use import JSONCleanerPlugin from 'esbuild-plugin-json-cleaner' or const JSONCleanerPlugin = require('esbuild-plugin-json-cleaner').default
Error: Build failed with 1 error: error: [plugin: JSONCleaner] Cannot find module 'esbuild'
esbuild is not installed as a dev dependency
fix
Run npm install esbuild --save-dev
error: [plugin: JSONCleaner] Failed to read file: src/data.json
Source file path is incorrect or file does not exist
fix
Check that src path is relative to the project root and file exists
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required for plugin to function
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-json-cleaner — npm install esbuild-plugin-json-cleaner · libregistry