esbuild-plugin-json-merge
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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

Package Sidebar

Install

npm i esbuild-plugin-json-merge

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

12 kB

Total Files

7

Last publish

Collaborators

  • karolis.sarapnickis