You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@rolldown/pluginutils

Package Overview
Dependencies
Maintainers
3
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rolldown/pluginutils

A utility library for building flexible, composable filter expressions that can be used in plugin hook filters of Rolldown/Vite/Rollup/Unplugin plugins.

1.0.0-beta.32
latest
Source
npmnpm
Version published
Weekly downloads
8.2M
19.71%
Maintainers
3
Weekly downloads
 
Created
Source

@rolldown/pluginutils

A utility library for building flexible, composable filter expressions that can be used in plugin hook filters of Rolldown/Vite/Rollup/Unplugin plugins.

Installation

pnpm add @rolldown/pluginutils

Usage

Simple Filters

import {
  exactRegex,
  makeIdFiltersToMatchWithQuery,
  prefixRegex,
} from '@rolldown/pluginutils';

// Match exactly 'foo.js'
const filter = exactRegex('foo.js');

// Match any id starting with 'lib/'
const prefix = prefixRegex('lib/');

// Match ids with query params (e.g. 'foo.js?bar')
const idFilters = makeIdFiltersToMatchWithQuery(['**/*.js', /\.ts$/]);

// Usage in a plugin to define a hook filter
const myPlugin = {
  resolveId: {
    filter: {
      id: [exactRegex('MY_ID_TO_CHECK'), /some-other-regex/],
    },
    handler(id) {
      // Your code here
    },
  },
};

Composable Filters

[!WARNING] Composable filters are not yet supported in Vite, Rolldown-Vite or unplugin. They can be used in Rolldown plugins only.

import { and, id, include, moduleType, query } from '@rolldown/pluginutils';

// Build a filter expression
const filterExpr = and(
  id(/\.ts$/),
  moduleType('ts'),
  query('foo', true),
);

// Usage in a plugin to define a hook filter
const myPlugin = {
  transform: {
    filter: [include(filterExpr)],
    handler(code, id, options) {
      // Your code here
    },
  },
};

API Reference

Simple Filters

  • exactRegex(str: string, flags?: string): RegExp — Matches the exact string.
  • prefixRegex(str: string, flags?: string): RegExp — Matches values with the given prefix.
  • makeIdFiltersToMatchWithQuery(input: string | RegExp | (string | RegExp)[]): string | RegExp | (string | RegExp)[] — Adapts filters to match ids with query params.

Composable Filters

  • and(...exprs) / or(...exprs) / not(expr) — Logical composition of filter expressions.
  • id(pattern, params?) — Filter by id (string or RegExp).
  • moduleType(type) — Filter by module type (e.g. 'js', 'tsx', or 'json').
  • code(pattern) — Filter by code content.
  • query(key, pattern) — Filter by query parameter.
  • include(expr) / exclude(expr) — Top-level include/exclude wrappers.
  • queries(obj) — Compose multiple query filters.

FAQs

Package last updated on 11 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.