A utility library for building flexible, composable filter expressions that can be used in plugin hook filters of Rolldown/Vite/Rollup/Unplugin plugins.
// 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.