Registry / web-framework / rollup-utils

rollup-utils

JSON →
library0.0.5jsnpmunverified

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-utils
INSTALL
IMPORT
SIG · ROLLUP-UTILS
R
rollup-utils
web-frameworkjavascriptv0.0.5
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.

* as utils
import * as utils from 'rollup-utils';
const utils = require('rollup-utils');
Package is ESM-only (ES module). CommonJS require() will cause an error.
addExtension
import { addExtension } from 'rollup-utils';
const addExtension = require('rollup-utils').addExtension;
Named export, not default export. Use named import syntax.
createFilter
import { createFilter } from 'rollup-utils';
import createFilter from 'rollup-utils';
createFilter is a named export, not default. Incorrect as default import.
attachScopes
import { attachScopes } from 'rollup-utils';
import { attachScopes } from '@rollup/pluginutils';
attachScopes is from 'rollup-utils', not '@rollup/pluginutils' (though the API is similar).
dataToEsm
import { dataToEsm } from 'rollup-utils';
Named export; use exactly as shown.

Shows how to import createFilter and use it in a Rollup plugin's transform hook to include only specific module IDs.

import { createFilter } from 'rollup-utils'; import resolve from '@rollup/plugin-node-resolve'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ resolve(), { name: 'my-plugin', transform(code, id) { const filter = createFilter('src/**/*.js', 'node_modules/**'); if (!filter(id)) return null; // Transform only included modules return code.replace(/__VERSION__/g, '1.0.0'); } } ] };
Debug
Known issues
breakingBreaking change: package is ESM-only. CommonJS require() will throw an error.
fix
Use import syntax instead of require().
affects: >=0.0.0
gotchacreateFilter returns a function that expects a string or unknown id, not an object. Passing an object may silently return false.
fix
Ensure you pass a string ID (e.g., the module path).
affects: >=0.0.0
gotchaaddExtension does not add an extension if the filename already has an extension (including '.' only).
fix
Check filename before calling addExtension if you want to force extension addition.
affects: >=0.0.0
gotchaattachScopes requires the AST to already have 'scope' property attached to nodes; it mutates the AST.
fix
Call attachScopes once on the AST, then walk and manage scope manually.
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/rollup-utils/dist/index.js from /path/to/index.js not supported.
Using CommonJS require() on an ESM-only package.
fix
Switch to import syntax (e.g., import { createFilter } from 'rollup-utils').
TypeError: (0 , _rollupUtils.createFilter) is not a function
Incorrect import style, probably using default import when createFilter is named export.
fix
Use import { createFilter } from 'rollup-utils' instead of import createFilter from 'rollup-utils'.
Cannot find module 'rollup'
rollup is a peer dependency and not installed automatically.
fix
Ensure rollup is installed: npm install rollup --save-dev
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies
path-browserifyrequiredReplaces Node.js 'path' module for browser compatibility
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-utils — npm install rollup-utils · libregistry