{"id":22302,"library":"rollup-pluginutils","title":"rollup-pluginutils","description":"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.","status":"maintenance","version":"2.8.2","language":"javascript","source_language":"en","source_url":"https://github.com/rollup/rollup-pluginutils","tags":["javascript","rollup","utils","typescript"],"install":[{"cmd":"npm install rollup-pluginutils","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-pluginutils","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-pluginutils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used internally by attachScopes for AST walking","package":"estree-walker","optional":false}],"imports":[{"note":"Named import; avoid default import. This package supports both ESM and CJS, but ESM is recommended.","wrong":"const createFilter = require('rollup-pluginutils').createFilter","symbol":"createFilter","correct":"import { createFilter } from 'rollup-pluginutils'"},{"note":"Named import; addExtension is not a default export.","wrong":"import addExtension from 'rollup-pluginutils'","symbol":"addExtension","correct":"import { addExtension } from 'rollup-pluginutils'"},{"note":"Named import; subpath imports are not supported.","wrong":"const attachScopes = require('rollup-pluginutils/attachScopes')","symbol":"attachScopes","correct":"import { attachScopes } from 'rollup-pluginutils'"},{"note":"Named import; this function is not part of Rollup core.","wrong":"import { dataToEsm } from 'rollup'","symbol":"dataToEsm","correct":"import { dataToEsm } from 'rollup-pluginutils'"}],"quickstart":{"code":"import { createFilter } from 'rollup-pluginutils';\nimport { rollup } from 'rollup';\n\nconst filter = createFilter(['src/**'], ['node_modules/**']);\n\nasync function build() {\n  const bundle = await rollup({\n    input: 'src/index.js',\n    plugins: [{\n      name: 'example',\n      transform(code, id) {\n        if (!filter(id)) return null;\n        // transform code\n        return code.replace(/__VERSION__/g, '1.0.0');\n      }\n    }]\n  });\n  await bundle.write({ file: 'dist/bundle.js', format: 'es' });\n}\n\nbuild().catch(err => console.error(err));","lang":"javascript","description":"Demonstrates using createFilter to include only files under src/ and exclude node_modules, then applying a simple transform."},"warnings":[{"fix":"Replace rollup-pluginutils with @rollup/pluginutils and update imports (e.g., import { createFilter } from '@rollup/pluginutils').","message":"rollup-pluginutils is deprecated in favor of @rollup/pluginutils","severity":"deprecated","affected_versions":">=2.0"},{"fix":"If migrating from v1, pass {resolve: string} as third argument instead of a string directly. Updated docs: createFilter(include, exclude, {resolve: '/path'}).","message":"createFilter signature changed with the addition of options object (resolve option) in v2.0.0","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure the AST is produced by acorn (Rollup's default parser) or a compatible parser that uses the same node types.","message":"attachScopes modifies the AST in place and expects estree-walker compatibility; it does not work with ASTs from other parsers.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Migrate to @rollup/pluginutils and use its attachScopes function.","message":"attachScopes may be removed in future major versions; consider using @rollup/pluginutils which provides similar functionality","severity":"deprecated","affected_versions":">=2.8.0"},{"fix":"If you relied on namedExports being false by default, explicitly set it to false in options.","message":"dataToEsm namedExports option changed behavior in v2.0.0, defaulting to true instead of false","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Do not rely on makeLegalIdentifier for generating unique identifiers; it only converts non-legal characters to underscores.","message":"makeLegalIdentifier does not guarantee uniqueness for all patterns; collisions can occur.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to @rollup/pluginutils for continued maintenance.","message":"Version 2.8.2 is the last release; no further updates will be published to this package.","severity":"deprecated","affected_versions":"<3.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install rollup-pluginutils@2.8.2 or if using newer Rollup, install @rollup/pluginutils.","cause":"Package not installed or incorrect import path","error":"Cannot find module 'rollup-pluginutils'"},{"fix":"Change import createFilter from 'rollup-pluginutils' to import { createFilter } from 'rollup-pluginutils'.","cause":"Default import used instead of named import","error":"TypeError: createFilter is not a function"},{"fix":"Run npm install estree-walker or ensure it is in dependencies.","cause":"Missing peer dependency estree-walker","error":"Error: Could not resolve 'estree-walker'"},{"fix":"Ensure the second argument is a string property name to attach, e.g., attachScopes(ast, 'scope').","cause":"attachScopes called with missing or incorrect arguments","error":"Error: AttachScopes requires an AST and identifier (like 'scope')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}