Registry / devops / rollup-pluginutils

rollup-pluginutils

JSON →
library2.8.2jsnpmunverified

Utility functions commonly needed by Rollup plugins, including file filtering (createFilter), scope analysis (attachScopes), identifier sanitization (makeLegalIdentifier), data-to-ESM conversion (dataToEsm), and extension handling (addExtension). This package is at version 2.8.2 and is stable but in maintenance mode; it has been superseded by `@rollup/pluginutils` for Rollup >= 1.0. TypeScript type definitions are included. Unlike ad-hoc implementations, these utilities are optimized for Rollup's plugin lifecycle and AST walking.

npm install rollup-pluginutils
INSTALL
IMPORT
SIG · ROLLUP-PLUGINUTILS
R
rollup-pluginutils
devopsjavascriptv2.8.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

createFilter
import { createFilter } from 'rollup-pluginutils'
const createFilter = require('rollup-pluginutils').createFilter
Named import; avoid default import. This package supports both ESM and CJS, but ESM is recommended.
addExtension
import { addExtension } from 'rollup-pluginutils'
import addExtension from 'rollup-pluginutils'
Named import; addExtension is not a default export.
attachScopes
import { attachScopes } from 'rollup-pluginutils'
const attachScopes = require('rollup-pluginutils/attachScopes')
Named import; subpath imports are not supported.
dataToEsm
import { dataToEsm } from 'rollup-pluginutils'
import { dataToEsm } from 'rollup'
Named import; this function is not part of Rollup core.

Demonstrates using createFilter to include only files under src/ and exclude node_modules, then applying a simple transform.

import { createFilter } from 'rollup-pluginutils'; import { rollup } from 'rollup'; const filter = createFilter(['src/**'], ['node_modules/**']); async function build() { const bundle = await rollup({ input: 'src/index.js', plugins: [{ name: 'example', transform(code, id) { if (!filter(id)) return null; // transform code return code.replace(/__VERSION__/g, '1.0.0'); } }] }); await bundle.write({ file: 'dist/bundle.js', format: 'es' }); } build().catch(err => console.error(err));
Debug
Known issues
deprecatedrollup-pluginutils is deprecated in favor of @rollup/pluginutils
fix
Replace rollup-pluginutils with @rollup/pluginutils and update imports (e.g., import { createFilter } from '@rollup/pluginutils').
affects: >=2.0
breakingcreateFilter signature changed with the addition of options object (resolve option) in v2.0.0
fix
If migrating from v1, pass {resolve: string} as third argument instead of a string directly. Updated docs: createFilter(include, exclude, {resolve: '/path'}).
affects: >=2.0.0
gotchaattachScopes modifies the AST in place and expects estree-walker compatibility; it does not work with ASTs from other parsers.
fix
Ensure the AST is produced by acorn (Rollup's default parser) or a compatible parser that uses the same node types.
affects: >=1.0.0
deprecatedattachScopes may be removed in future major versions; consider using @rollup/pluginutils which provides similar functionality
fix
Migrate to @rollup/pluginutils and use its attachScopes function.
affects: >=2.8.0
breakingdataToEsm namedExports option changed behavior in v2.0.0, defaulting to true instead of false
fix
If you relied on namedExports being false by default, explicitly set it to false in options.
affects: >=2.0.0
gotchamakeLegalIdentifier does not guarantee uniqueness for all patterns; collisions can occur.
fix
Do not rely on makeLegalIdentifier for generating unique identifiers; it only converts non-legal characters to underscores.
affects: >=1.0.0
deprecatedVersion 2.8.2 is the last release; no further updates will be published to this package.
fix
Switch to @rollup/pluginutils for continued maintenance.
affects: <3.0
Errors
Common errors & fixes
Cannot find module 'rollup-pluginutils'
Package not installed or incorrect import path
fix
Run npm install rollup-pluginutils@2.8.2 or if using newer Rollup, install @rollup/pluginutils.
TypeError: createFilter is not a function
Default import used instead of named import
fix
Change import createFilter from 'rollup-pluginutils' to import { createFilter } from 'rollup-pluginutils'.
Error: Could not resolve 'estree-walker'
Missing peer dependency estree-walker
fix
Run npm install estree-walker or ensure it is in dependencies.
Error: AttachScopes requires an AST and identifier (like 'scope')
attachScopes called with missing or incorrect arguments
fix
Ensure the second argument is a string property name to attach, e.g., attachScopes(ast, 'scope').
Upgrade
Version history
2.8.2latest on npm
Audit
Dependencies
estree-walkerrequiredUsed internally by attachScopes for AST walking
Agent activity
2 hits · last 30 days
node
2
Resources