A set of utility functions for Rollup plugins, forked from @rollup/pluginutils but using path-browserify instead of the Node.js path module to support browser environments. Version 0.0.5 (released on npm, but no release cadence noted). Requires Node >=14.0.0 and Rollup ^1.20.0||^2.0.0||^3.0.0||^4.0.0. Ships TypeScript type definitions. Key differentiators from @rollup/pluginutils: browser compatibility via path-browserify dependency. Includes addExtension, attachScopes, createFilter, dataToEsm, extractAssignedNames, makeLegalIdentifier, and normalizePath functions.
npm install rollup-utilsVerified import paths — ran on the pinned version, not inferred.
Shows how to import createFilter and use it in a Rollup plugin's transform hook to include only specific module IDs.
Use import syntax instead of require().
Ensure you pass a string ID (e.g., the module path).
Check filename before calling addExtension if you want to force extension addition.
Call attachScopes once on the AST, then walk and manage scope manually.
Switch to import syntax (e.g., import { createFilter } from 'rollup-utils').Use import { createFilter } from 'rollup-utils' instead of import createFilter from 'rollup-utils'.Ensure rollup is installed: npm install rollup --save-dev