Registry / devops / rollup-plugin-prettier

rollup-plugin-prettier

JSON →
library4.1.2jsnpmunverified

Rollup plugin to format the final bundle with Prettier. Current stable version is 4.1.2, supports Prettier ^1.0.0 || ^2.0.0 || ^3.0.0 and Rollup ^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0. Ships TypeScript types. Key differentiators: integrates Prettier as a Rollup plugin, handles source map generation by computing diffs. Release cadence is irregular, with recent updates focused on dependency upgrades and Rollup/Prettier version support.

npm install rollup-plugin-prettier
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-PRET
R
rollup-plugin-prettier
devopsjavascriptv4.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import prettier from 'rollup-plugin-prettier'
import { prettier } from 'rollup-plugin-prettier'
Plugin is a default export, not named.
default
const prettier = require('rollup-plugin-prettier')
const { prettier } = require('rollup-plugin-prettier')
CJS default import via require.
types
import type { PrettierOptions } from 'rollup-plugin-prettier'
TypeScript types are included, but typically not needed as options are inferred.

Configures Rollup to format output bundle with Prettier using tab width 2 and single quotes.

import prettier from 'rollup-plugin-prettier'; import { defineConfig } from 'rollup'; export default defineConfig({ input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'es', }, plugins: [ prettier({ tabWidth: 2, singleQuote: true, parser: 'babel', }), ], });
Debug
Known issues
breakingIn v1.0.0, prettier dependency changed from direct to peer dependency.
fix
Install prettier as a devDependency: npm install --save-dev prettier
affects: <1.0.0
breakingIn v4.0.0, support for prettier ^3.0.0 added; older versions may still work but are not tested.
fix
Upgrade plugin to v4.0.0 or later to use prettier v3
affects: <4.0.0
deprecatedThe sourceMap option (camelCase) was deprecated in v1.0.0 in favor of sourcemap (all lowercase).
fix
Use sourcemap: true instead of sourceMap: true
affects: >=1.0.0
gotchaSource map generation may be slow for large bundles because the plugin computes diffs to generate a source map.
fix
Disable source map in plugin options if not needed, or accept slower builds.
affects: >=0.4.0
gotchaThe plugin runs Prettier synchronously (before v3.1.0) or asynchronously (v3.1.0+), but this is transparent to the user.
fix
No action needed; asynchronous mode prepares for Prettier v3 async API.
affects: >=3.1.0
Errors
Common errors & fixes
TypeError: prettier is not a function
Importing named export instead of default export.
fix
Use import prettier from 'rollup-plugin-prettier' (default import) instead of import { prettier } from 'rollup-plugin-prettier'.
Error: Cannot find module 'prettier'
Prettier is a peer dependency not installed.
fix
Run npm install --save-dev prettier to install it.
Error: RollupError: Could not resolve 'rollup-plugin-prettier'
Plugin not installed.
fix
Run npm install --save-dev rollup-plugin-prettier
Error: The 'sourceMap' option is deprecated. Use 'sourcemap' instead.
Using deprecated camelCase option.
fix
Change sourceMap: true to sourcemap: true in plugin options.
Upgrade
Version history
4.1.2latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: the actual formatter
rolluprequiredPeer dependency: Rollup bundler
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-plugin-prettier — npm install rollup-plugin-prettier · libregistry