rollup-plugin-esformatter
raw JSON → 3.1.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that runs esformatter on the final bundle, providing JavaScript code formatting/beautification. Current stable version is 3.1.0, supporting Rollup ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0. It requires Node >=14. Drops support for older Rollup versions and Node <14 as of v3.0.0. Generates source maps by computing diff between original and formatted bundle, but source maps are disabled by default due to performance cost. Useful for consistent code style in build output, alternative to rollup-plugin-prettier. Maintenance mode, with infrequent updates.
Common errors
error Error: Cannot find module 'rollup-plugin-esformatter' ↓
cause Missing or incorrectly installed package.
fix
Run 'npm install --save-dev rollup-plugin-esformatter' or 'yarn add --dev rollup-plugin-esformatter'.
error TypeError: esformatter is not a function ↓
cause Incorrect import: using named import instead of default import.
fix
Use 'import esformatter from 'rollup-plugin-esformatter'' or 'const esformatter = require('rollup-plugin-esformatter')'.
error Error: Rollup plugin 'rollup-plugin-esformatter' requires a peer dependency but none was installed. ↓
cause Missing peer dependency 'rollup'.
fix
Install rollup: 'npm install --save-dev rollup' (ensure version ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0).
error Warning: The 'sourceMap' option is deprecated. Use 'sourcemap' instead. ↓
cause Using deprecated camelCase option name.
fix
Replace 'sourceMap' with 'sourcemap' in plugin options.
Warnings
breaking Version 2.0.0 removed support for Node <10. Version 3.0.0 removed support for Node <14. ↓
fix Upgrade Node to >=14 for v3.x, >=10 for v2.x.
deprecated The 'sourceMap' option (camelCase) was deprecated in v0.6.0 and removed in v1.0.0; use 'sourcemap' (lowercase) instead. ↓
fix Replace 'sourceMap' with 'sourcemap' in plugin options.
gotcha Source maps are disabled by default. To enable, set sourcemap: true in plugin options and ensure sourcemap: true in Rollup output options. ↓
fix Explicitly set sourcemap: true in both Rollup output config and plugin options.
gotcha The plugin applies esformatter on the whole bundle after all transforms, not per-module. This may affect formatting consistency. ↓
fix Be aware that final bundle formatting may differ from per-module formatting. Use esformatter with compatible options.
deprecated Greenkeeper badge in README indicates automated dependency updates are handled, but Greenkeeper is deprecated in favor of Renovate or Dependabot. ↓
fix No action needed; badge is just informational.
Install
npm install rollup-plugin-esformatter yarn add rollup-plugin-esformatter pnpm add rollup-plugin-esformatter Imports
- esformatter wrong
const esformatter = require('rollup-plugin-esformatter')correctimport esformatter from 'rollup-plugin-esformatter' - default export (plugin function) wrong
const { esformatter } = require('rollup-plugin-esformatter')correctconst esformatter = require('rollup-plugin-esformatter') - TypeScript types
import esformatter from 'rollup-plugin-esformatter' // See @types/rollup-plugin-esformatter or inline type: (options?: EsFormatterOptions) => Plugin
Quickstart
import esformatter from 'rollup-plugin-esformatter';
export default {
input: './src/index.js',
output: {
file: './dist/bundle.js',
format: 'es',
},
plugins: [
esformatter({
indent: {
value: ' ',
},
// additional esformatter options
}),
],
};