Registry / devops / postinstall-esbuild

postinstall-esbuild

JSON →
library0.15.5jsnpmunverified

Postinstall plugin that bundles and minifies JavaScript and CSS files using esbuild. Version 0.15.5, actively maintained. Supports inputs as Buffers, remote URLs, or local paths, and concatenates bundles on output. Differentiates by integrating with the postinstall system and offering options for browserslist-based minification and source maps.

npm install postinstall-esbuild
INSTALL
IMPORT
SIG · POSTINSTALL-ESBUIL
P
postinstall-esbuild
devopsjavascriptv0.15.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import postinstallEsbuild from 'postinstall-esbuild';
const postinstallEsbuild = require('postinstall-esbuild');
ESM default import works for Node 14+ with esm support.
default
const postinstallEsbuild = require('postinstall-esbuild');
const { postinstallEsbuild } = require('postinstall-esbuild');
CommonJS require is supported in older Node versions.
default
import pkg from 'postinstall-esbuild'; const postinstallEsbuild = pkg.default;
import * as postinstallEsbuild from 'postinstall-esbuild';
Only needed if using TypeScript with esModuleInterop: false. Prefer default import.

Bundles local and remote JS files, outputs minified bundle with sourcemap.

import postinstallBundle from 'postinstall-esbuild'; import { readFileSync } from 'fs'; const inputs = [ { path: 'src/index.js', content: readFileSync('src/index.js') }, { path: 'https://unpkg.com/lodash@4.17.21/lodash.min.js' }, ]; await postinstallBundle(inputs, 'dist/bundle.js', { minify: true, sourceMap: true, browsers: 'last 1 chrome versions', }); console.log('Bundled and minified successfully.');
Debug
Known issues
gotchaCSS source maps may not be correct when using lightningcss; esbuild does not receive the map from lightning.
fix
Expect CSS source maps to be inaccurate. Disable sourceMap for CSS if accuracy is needed.
affects: >=0.0.0
gotchaPassing Buffer inputs requires sourceMap: false.
fix
Set sourceMap: false when passing Buffer objects in inputs.
affects: >=0.0.0
deprecatedThe direct require pattern is being phased out; ESM imports are preferred.
fix
Use ESM import instead of require.
affects: >=0.15.0
Errors
Common errors & fixes
TypeError: postinstallEsbuild is not a function
Using destructuring require where default export is a function.
fix
Replace const { postinstallEsbuild } = require('postinstall-esbuild') with const postinstallEsbuild = require('postinstall-esbuild').
Error: Input must be a string, Buffer, or URL
Invalid input type passed to the plugin.
fix
Ensure each input is an object with path (string) and content (Buffer/string) or a string URL.
Cannot find module 'esbuild'
esbuild is not installed as a dependency.
fix
Run npm install esbuild --save-dev
Upgrade
Version history
0.15.5latest on npm
Audit
Dependencies
postinstallrequiredPlugin system dependency; postinstall-esbuild is a command plugin for postinstall.
Agent activity
10 hits · last 30 days
node
9
Amazon
1
Resources
postinstall-esbuild — npm install postinstall-esbuild · libregistry