{"id":25297,"library":"esbuild-manifest-plugin","title":"esbuild-manifest-plugin","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/makandra/esbuild-manifest-plugin","tags":["javascript"],"install":[{"cmd":"npm install esbuild-manifest-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-manifest-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-manifest-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to work","package":"esbuild","optional":false}],"imports":[{"note":"Package exports a function directly, not as default export. Use require() as shown.","wrong":"const manifestPlugin = require('esbuild-manifest-plugin').default","symbol":"default","correct":"const manifestPlugin = require('esbuild-manifest-plugin')"},{"note":"ESM default import works because the package uses module.exports = function. This is the preferred way for ESM projects.","wrong":"import { default as manifestPlugin } from 'esbuild-manifest-plugin'","symbol":"manifestPlugin","correct":"import manifestPlugin from 'esbuild-manifest-plugin'"},{"note":"No types are exported. Infer types or define manually. The plugin is JavaScript-only without TypeScript definitions.","wrong":"import { ManifestPluginOptions } from 'esbuild-manifest-plugin'","symbol":"ManifestPluginOptions","correct":"type ManifestPluginOptions = Parameters<typeof manifestPlugin>[0]"}],"quickstart":{"code":"const esbuild = require('esbuild');\nconst manifestPlugin = require('esbuild-manifest-plugin');\nconst path = require('path');\n\nesbuild.build({\n  entryPoints: ['application.js'],\n  entryNames: '[dir]/[name]-[hash]',\n  assetNames: '[dir]/[name]-[hash]',\n  bundle: true,\n  outdir: path.join(__dirname, 'public/assets'),\n  plugins: [manifestPlugin()]\n}).then(() => {\n  console.log('Build complete. Manifest written to outdir.');\n}).catch(() => process.exit(1));","lang":"javascript","description":"Build an entry point and generate a manifest.json with content-hashed filenames. The plugin automatically enables metafile."},"warnings":[{"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).","message":"The plugin automatically enables the 'metafile' option in esbuild if not already set. This may cause unexpected metafile output size for large builds.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set nodeModulesPrefix to '~' or false to avoid collisions. Review generated manifest for duplicates.","message":"nodeModulesPrefix 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"","message":"No deprecations yet as plugin is v1.0.0.","severity":"deprecated","affected_versions":""},{"fix":"","message":"No breaking changes reported yet.","severity":"breaking","affected_versions":""}],"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-manifest-plugin' to install it.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'esbuild-manifest-plugin'"},{"fix":"Use 'const manifestPlugin = require('esbuild-manifest-plugin');'","cause":"Incorrect import: using default import from CommonJS module.","error":"TypeError: manifestPlugin is not a function"},{"fix":"Remove 'metafile: false' from your esbuild config.","cause":"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.","error":"Error: The plugin \"esbuild-manifest-plugin\" requires the \"metafile\" option"},{"fix":"Ensure outdir exists and is writable. Check esbuild logs for preceding errors.","cause":"Internal error in plugin, possibly due to missing outdir or write permissions.","error":"Error: Build failed with 1 error: error: [plugin: esbuild-manifest-plugin] Manifest generation failed"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}