Skip to content

Function: exactRegex()

  • Exported from: rolldown/filter
  • Type: (str: string, flags?: string) => RegExp

Constructs a RegExp that matches the exact string specified.

This is useful for plugin hook filters.

Parameters

str

string

the string to match.

flags?

string

flags for the RegExp.

Returns

RegExp

Example

ts
import { exactRegex } from '@rolldown/pluginutils';
const plugin = {
  name: 'plugin',
  resolveId: {
    filter: { id: exactRegex('foo') },
    handler(id) {} // will only be called for `foo`
  }
}