0.1.0 • Published 5 months ago

esbuild-plugin-json-merge v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

esbuild-plugin-json-merge

npm version Node.js CI License: MIT

Merging multiple JSON sources into one via esbuild pipeline.

Installation

npm i esbuild-plugin-json-merge -D

or

yarn add esbuild-plugin-json-merge --dev

Usage

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));
0.1.0

5 months ago

0.0.3

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago