Registry / devops / esbuild-manifest-plugin

esbuild-manifest-plugin

JSON →
library1.0.0jsnpmunverified

An esbuild plugin (v1.0.0, released 2024) that generates a manifest.json mapping input filenames to their output filenames after digestion with content hashes or directory nesting. It automatically enables esbuild's metafile option and optionally rewrites node_modules asset paths for convenience. Unlike general asset plugins, it specifically targets bundlers needing a Rails-like manifest for cache busting or server-side filename resolution. Updated infrequently, with a focus on simplicity and interoperability with esbuild-sass-plugin.

npm install esbuild-manifest-plugin
INSTALL
IMPORT
SIG · ESBUILD-MANIFEST-P
E
esbuild-manifest-plugin
devopsjavascriptv1.0.0
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
const manifestPlugin = require('esbuild-manifest-plugin')
const manifestPlugin = require('esbuild-manifest-plugin').default
Package exports a function directly, not as default export. Use require() as shown.
manifestPlugin
import manifestPlugin from 'esbuild-manifest-plugin'
import { default as manifestPlugin } from 'esbuild-manifest-plugin'
ESM default import works because the package uses module.exports = function. This is the preferred way for ESM projects.
ManifestPluginOptions
type ManifestPluginOptions = Parameters<typeof manifestPlugin>[0]
import { ManifestPluginOptions } from 'esbuild-manifest-plugin'
No types are exported. Infer types or define manually. The plugin is JavaScript-only without TypeScript definitions.

Build an entry point and generate a manifest.json with content-hashed filenames. The plugin automatically enables metafile.

const esbuild = require('esbuild'); const manifestPlugin = require('esbuild-manifest-plugin'); const path = require('path'); esbuild.build({ entryPoints: ['application.js'], entryNames: '[dir]/[name]-[hash]', assetNames: '[dir]/[name]-[hash]', bundle: true, outdir: path.join(__dirname, 'public/assets'), plugins: [manifestPlugin()] }).then(() => { console.log('Build complete. Manifest written to outdir.'); }).catch(() => process.exit(1));
Debug
Known issues
gotchaThe plugin automatically enables the 'metafile' option in esbuild if not already set. This may cause unexpected metafile output size for large builds.
fix
Ensure your build has enough memory or explicitly disable metafile if you don't need it (but then the plugin will enable it anyway).
affects: >=1.0.0
gotchanodeModulesPrefix default is empty string, which rewrites node_modules paths to be relative without prefix (e.g., 'example-lib/image.png'). This may collide with your own asset paths if you have files with the same names.
fix
Set nodeModulesPrefix to '~' or false to avoid collisions. Review generated manifest for duplicates.
affects: >=1.0.0
deprecatedNo deprecations yet as plugin is v1.0.0.
breakingNo breaking changes reported yet.
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-manifest-plugin'
Package not installed or not in node_modules.
fix
Run 'npm install -D esbuild-manifest-plugin' to install it.
TypeError: manifestPlugin is not a function
Incorrect import: using default import from CommonJS module.
fix
Use 'const manifestPlugin = require('esbuild-manifest-plugin');'
Error: The plugin "esbuild-manifest-plugin" requires the "metafile" option
If user explicitly set metafile: false, plugin reports error (though code says it auto-enables). Actually the plugin always forces metafile true, but if esbuild refuses, this may appear.
fix
Remove 'metafile: false' from your esbuild config.
Error: Build failed with 1 error: error: [plugin: esbuild-manifest-plugin] Manifest generation failed
Internal error in plugin, possibly due to missing outdir or write permissions.
fix
Ensure outdir exists and is writable. Check esbuild logs for preceding errors.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency required for plugin to work
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
esbuild-manifest-plugin — npm install esbuild-manifest-plugin · libregistry