Merging multiple JSON sources into one via esbuild pipeline.
npm i esbuild-plugin-json-merge -D
or
yarn add esbuild-plugin-json-merge --dev
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));
Type: (string | object)[]
An array of glob patterns or JSON objects that should be merged.
Type: string
JSON output destination.
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));