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
muslnode 18–223 runs
build_error
glibcnode 18–223 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.fixUpdate 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.fixUse 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).fixSet 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.fixEnsure 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.
fixUpgrade 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.
fixUpdate 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.
fixUse 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.
fixEnsure import is correct: import brotli from 'rollup-plugin-brotli' or import { brotli } from 'rollup-plugin-brotli'. Audit
Dependencies
rolluprequiredpeer dependency required to use as a rollup plugin