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-pluginutilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates using createFilter to include only files under src/ and exclude node_modules, then applying a simple transform.
Replace rollup-pluginutils with @rollup/pluginutils and update imports (e.g., import { createFilter } from '@rollup/pluginutils').If migrating from v1, pass {resolve: string} as third argument instead of a string directly. Updated docs: createFilter(include, exclude, {resolve: '/path'}).Ensure the AST is produced by acorn (Rollup's default parser) or a compatible parser that uses the same node types.
Migrate to @rollup/pluginutils and use its attachScopes function.
If you relied on namedExports being false by default, explicitly set it to false in options.
Do not rely on makeLegalIdentifier for generating unique identifiers; it only converts non-legal characters to underscores.
Switch to @rollup/pluginutils for continued maintenance.
Run npm install rollup-pluginutils@2.8.2 or if using newer Rollup, install @rollup/pluginutils.
Change import createFilter from 'rollup-pluginutils' to import { createFilter } from 'rollup-pluginutils'.Run npm install estree-walker or ensure it is in dependencies.
Ensure the second argument is a string property name to attach, e.g., attachScopes(ast, 'scope').