{"id":25382,"library":"esbuild-plugin-package-json","title":"esbuild-plugin-package-json","description":"An esbuild plugin that prepares package.json for publishing by removing unnecessary fields (e.g., scripts, devDependencies) and copying it to the output folder. Version 2.0.0 is the latest stable release, with active development. It is designed for developers who want to publish clean packages directly from esbuild builds. Differentiators include zero configuration defaults and support for custom output paths.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/simonkovtyk/esbuild-plugin-package-json","tags":["javascript","frontend","backend","packages","esbuild","build","esbuild plugin","esbuild tool","build plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-package-json","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-package-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-package-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"esbuild is required as a peer dependency to use this plugin.","package":"esbuild","optional":false}],"imports":[{"note":"This package uses named export; default import will not work.","wrong":"import packageJsonPlugin from 'esbuild-plugin-package-json'","symbol":"packageJsonPlugin","correct":"import { packageJsonPlugin } from 'esbuild-plugin-package-json'"},{"note":"CommonJS users must destructure the named export.","wrong":"const packageJsonPlugin = require('esbuild-plugin-package-json')","symbol":"packageJsonPlugin","correct":"const { packageJsonPlugin } = require('esbuild-plugin-package-json')"},{"note":"TypeScript users can import the options type for plugin configuration.","symbol":"type PackageJsonPluginOptions","correct":"import type { PackageJsonPluginOptions } from 'esbuild-plugin-package-json'"}],"quickstart":{"code":"import { packageJsonPlugin } from 'esbuild-plugin-package-json';\nimport esbuild from 'esbuild';\n\nawait esbuild.build({\n  entryPoints: ['src/index.ts'],\n  outdir: 'dist',\n  bundle: true,\n  plugins: [\n    packageJsonPlugin({\n      lifecycle: 'onEnd',\n      overrideOut: 'dist',\n      // overridePackageJson: './src', // optional custom path\n    }),\n  ],\n});","lang":"typescript","description":"Demonstrates basic usage of the plugin with esbuild, configuring the lifecycle and output directory."},"warnings":[{"fix":"Use `import { packageJsonPlugin } from 'esbuild-plugin-package-json'` instead.","message":"Version 2.0.0 changed the export from default to named export. Old code using `import packageJsonPlugin from 'esbuild-plugin-package-json'` will break.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Explicitly set `overrideOut` to your intended output directory.","message":"If `overrideOut` is not set, the plugin copies package.json to esbuild's default output directory, which may not be desired if multiple output paths are configured.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Manually specify additional fields to remove in your own build script.","message":"The plugin only removes specific fields (scripts, devDependencies) by default. Other fields like 'private' are not automatically removed.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use the default `onEnd` lifecycle to ensure the build is complete.","message":"Using `lifecycle: 'onStart'` may cause the package.json to be copied before the build produces the final output, potentially leading to outdated files.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -D esbuild-plugin-package-json` to install it as a dev dependency.","cause":"The package is not installed or is missing from node_modules.","error":"Error: Cannot find module 'esbuild-plugin-package-json'"},{"fix":"Use `import { packageJsonPlugin } from 'esbuild-plugin-package-json'` instead of `import packageJsonPlugin from ...`.","cause":"Using a default import when the package exports a named function.","error":"TypeError: packageJsonPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}