Registry / devops / rollup-plugin-brotli

rollup-plugin-brotli

JSON →
library3.1.0jsnpmunverified

Rollup plugin that creates Brotli-compressed .br artifacts for your bundle. Current stable version is 3.1.0, maintained with irregular releases. Uses Node.js built-in zlib.createBrotliCompress (requires Node >=11.7.0). Differentiates from alternatives like rollup-plugin-gzip by focusing solely on Brotli and leveraging native Node APIs. Offers configurable options: file extension filtering via RegExp test, brotli compression params (mode, quality), additional files list, and minSize threshold to skip small files.

npm install rollup-plugin-brotli
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-BROT
R
rollup-plugin-brotli
devopsjavascriptv3.1.0
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

brotli
import brotli from 'rollup-plugin-brotli'
const brotli = require('rollup-plugin-brotli')
Default export; ESM-only for rollup >=2, but package also supports CJS require.
brotli (as named export)
import { brotli } from 'rollup-plugin-brotli'
Named export available since v3.0.0; both default and named exports are the same function.
Plugin type
import { Plugin } from 'rollup'
TypeScript users should import Plugin type from rollup, not from this package (no types exported).

Shows typical rollup configuration using rollup-plugin-brotli with all options.

import brotli from 'rollup-plugin-brotli'; import zlib from 'zlib'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ brotli({ test: /\.(js|css|html|txt|xml|json|svg|ico|ttf|otf|eot)$/, options: { params: { [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_GENERIC, [zlib.constants.BROTLI_PARAM_QUALITY]: 7 } }, additional: ['dist/bundle.css'], minSize: 1000 }) ] };
Debug
Known issues
breakingv2.0.0 dropped Brotli implementation from node-brotli package in favor of native Node.js zlib.createBrotliCompress.
fix
Update Node to >=11.7.0 and remove node-brotli from dependencies.
affects: >=2.0.0
deprecatedv2.0.0 removed the `test` option? (Actually added later in v3.1.0, so not deprecated.)
gotchaIf output.file is used (single bundle) and no output.dir, the plugin may create .br file next to the output file; but if output.dir is used, it compresses all output chunks matching the test pattern.
fix
Use output.dir for multi-chunk outputs; ensure file extension matches test regex.
affects: >=1.0.0
gotchaDefault quality is 11 (maximum compression), which is slow. For faster builds, set quality lower (e.g., 4 or 7).
fix
Set options.params[zlib.constants.BROTLI_PARAM_QUALITY] to a lower value.
affects: >=1.0.0
breakingv2.0.0 changed from using the `node-brotli` npm package to Node's built-in zlib. This is a breaking change because it requires Node >=11.7.0 and the option names changed.
fix
Ensure Node >=11.7.0, use zlib constants instead of node-brotli options.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Node >= 11.7.0 is required for the built-in brotli support
Node version < 11.7.0 does not have native Brotli support; plugin since v2.0.0 uses native zlib.
fix
Upgrade Node to version >=11.7.0.
The 'test' option has been removed. Use the 'test' option to filter files.
Misreading documentation; actually test option was added in v3.1.0 but some users may use older version.
fix
Update plugin to v3.1.0 or later, or use the include/exclude pattern? Actually no include/exclude, so use test.
Cannot read property 'fileName' of undefined
Occurs when using output.file and the plugin expects output.dir.
fix
Use output.dir instead of output.file, or adapt plugin configuration.
TypeError: brotli is not a function
Using named import incorrectly: import { brotli } from 'rollup-plugin-brotli' works, but if using default import with wrong syntax.
fix
Ensure import is correct: import brotli from 'rollup-plugin-brotli' or import { brotli } from 'rollup-plugin-brotli'.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required to use as a rollup plugin
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-brotli — npm install rollup-plugin-brotli · libregistry