esbuild-plugin-json-merge
v0.1.0
Published
esbuild plugin to merge multiple JSON sources into one
Maintainers
Readme
esbuild-plugin-json-merge
Merging multiple JSON sources into one via esbuild pipeline.
Installation
npm i esbuild-plugin-json-merge -Dor
yarn add esbuild-plugin-json-merge --devUsage
const esbuild = require('esbuild');
const jsonMerge = require('esbuild-plugin-json-merge');
const { version, name, description } = require('./package.json');
esbuild
.build({
entryPoints: ['src/index.js'],
outdir: 'build',
plugins: [
jsonMerge({
entryPoints: ['src/manifest.json', { version, name, description }],
outfile: 'manifest.json',
}),
],
})
.catch(() => process.exit(1));Options
entryPoints
Type: (string | object)[]
An array of glob patterns or JSON objects that should be merged.
outfile
Type: string
JSON output destination.
merge
Type: (items: JSONValue[]) => JSONValue
By default the merge function uses Object.assign.
const esbuild = require('esbuild');
const jsonMerge = require('esbuild-plugin-json-merge');
const { defaultComposer } = require('default-composer');
const { version, name, description } = require('./package.json');
esbuild
.build({
entryPoints: ['src/index.js'],
outdir: 'build',
plugins: [
jsonMerge({
entryPoints: ['src/manifest.json', { version, name, description }],
outfile: 'manifest.json',
merge: (items) => defaultComposer(...items), //Custom merge
}),
],
})
.catch(() => process.exit(1));