{"id":25387,"library":"esbuild-plugin-prettier","title":"esbuild-plugin-prettier","description":"An esbuild plugin that automatically formats processed files with Prettier. Version 1.0.0 is the initial release. It runs Prettier on each file that matches the filter regex (default: /[jt]sx?|s?css/) and writes changes back. This plugin is useful in watch mode to keep code formatted without manual intervention. It is lightweight and configurable, but note that Prettier rewriting may conflict with esbuild's incremental build caching.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/dom111/esbuild-plugin-prettier","tags":["javascript"],"install":[{"cmd":"npm install esbuild-plugin-prettier","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-prettier","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-prettier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required at runtime for formatting files","package":"prettier","optional":false}],"imports":[{"note":"Package ships as ESM. Use dynamic import if in CommonJS context.","wrong":"const esbuildPluginPrettier = require('esbuild-plugin-prettier')","symbol":"default","correct":"import esbuildPluginPrettier from 'esbuild-plugin-prettier'"},{"note":"The default export is the plugin function; no named exports.","wrong":"import { plugin } from 'esbuild-plugin-prettier'","symbol":"esbuildPluginPrettier (default)","correct":"import plugin from 'esbuild-plugin-prettier'"},{"note":"Options type is exported for TypeScript users, but not required.","wrong":"","symbol":"type Options","correct":"import type { Options } from 'esbuild-plugin-prettier'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport prettierPlugin from 'esbuild-plugin-prettier';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  bundle: true,\n  outfile: 'dist/bundle.js',\n  plugins: [\n    prettierPlugin({\n      filter: /\\.js$/,\n      prettierOptions: {\n        semi: false,\n        singleQuote: true,\n      },\n    }),\n  ],\n});\nconsole.log('Build complete with Prettier formatting!');","lang":"typescript","description":"Demonstrates using the plugin in an esbuild build with custom filter and Prettier options."},"warnings":[{"fix":"Consider disabling the plugin for production builds or using onEnd instead of onLoad.","message":"Prettier rewriting files can invalidate esbuild's cache on every rebuild, slowing down watch mode.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use prettier's asynchronous API if performance is critical; consider an alternative plugin.","message":"The plugin uses prettier's sync API internally; large files may block the event loop.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set filter to only include file types you have prettier plugins installed for.","message":"Default filter includes CSS and SCSS files, but prettier may not have a parser for them unless configured.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: npm install prettier","cause":"Missing peer dependency 'prettier'","error":"Error: Cannot find module 'prettier'"},{"fix":"Use prettier v2 or configure the plugin to work with prettier v3 (requires plugin update)","cause":"Using a version of prettier that does not export 'format' (prettier v3+ uses ESM default export)","error":"TypeError: prettier.format is not a function"},{"fix":"Specify a custom filter that matches your file extensions","cause":"Plugin filter regex does not match any input files","error":"Error: No matching files found for filter: /[jt]sx?|s?css/"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}