{"id":21931,"library":"rollup-plugin-brotli","title":"rollup-plugin-brotli","description":"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.","status":"active","version":"3.1.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/keithamus/rollup-plugin-brotli","tags":["javascript","rollup","rollup-plugin","brotli","compress"],"install":[{"cmd":"npm install rollup-plugin-brotli","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-brotli","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-brotli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to use as a rollup plugin","package":"rollup","optional":false}],"imports":[{"note":"Default export; ESM-only for rollup >=2, but package also supports CJS require.","wrong":"const brotli = require('rollup-plugin-brotli')","symbol":"brotli","correct":"import brotli from 'rollup-plugin-brotli'"},{"note":"Named export available since v3.0.0; both default and named exports are the same function.","wrong":"","symbol":"brotli (as named export)","correct":"import { brotli } from 'rollup-plugin-brotli'"},{"note":"TypeScript users should import Plugin type from rollup, not from this package (no types exported).","wrong":"","symbol":"Plugin type","correct":"import { Plugin } from 'rollup'"}],"quickstart":{"code":"import brotli from 'rollup-plugin-brotli';\nimport zlib from 'zlib';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    brotli({\n      test: /\\.(js|css|html|txt|xml|json|svg|ico|ttf|otf|eot)$/,\n      options: {\n        params: {\n          [zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_GENERIC,\n          [zlib.constants.BROTLI_PARAM_QUALITY]: 7\n        }\n      },\n      additional: ['dist/bundle.css'],\n      minSize: 1000\n    })\n  ]\n};","lang":"javascript","description":"Shows typical rollup configuration using rollup-plugin-brotli with all options."},"warnings":[{"fix":"Update Node to >=11.7.0 and remove node-brotli from dependencies.","message":"v2.0.0 dropped Brotli implementation from node-brotli package in favor of native Node.js zlib.createBrotliCompress.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"","message":"v2.0.0 removed the `test` option? (Actually added later in v3.1.0, so not deprecated.)","severity":"deprecated","affected_versions":""},{"fix":"Use output.dir for multi-chunk outputs; ensure file extension matches test regex.","message":"If 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set options.params[zlib.constants.BROTLI_PARAM_QUALITY] to a lower value.","message":"Default quality is 11 (maximum compression), which is slow. For faster builds, set quality lower (e.g., 4 or 7).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure Node >=11.7.0, use zlib constants instead of node-brotli options.","message":"v2.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.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade Node to version >=11.7.0.","cause":"Node version < 11.7.0 does not have native Brotli support; plugin since v2.0.0 uses native zlib.","error":"Error: Node >= 11.7.0 is required for the built-in brotli support"},{"fix":"Update plugin to v3.1.0 or later, or use the include/exclude pattern? Actually no include/exclude, so use test.","cause":"Misreading documentation; actually test option was added in v3.1.0 but some users may use older version.","error":"The 'test' option has been removed. Use the 'test' option to filter files."},{"fix":"Use output.dir instead of output.file, or adapt plugin configuration.","cause":"Occurs when using output.file and the plugin expects output.dir.","error":"Cannot read property 'fileName' of undefined"},{"fix":"Ensure import is correct: import brotli from 'rollup-plugin-brotli' or import { brotli } from 'rollup-plugin-brotli'.","cause":"Using named import incorrectly: import { brotli } from 'rollup-plugin-brotli' works, but if using default import with wrong syntax.","error":"TypeError: brotli is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}