You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to port a plugin that uses `createFilter()` to hook filters
it's hard keep the functionality 100% the same, as `createFilter()` does
various pre-processing, like normalising paths and, resolving relative
paths, exluding paths which contain \0, etc.
To make porting easier, provide a `createHookFilter()` which instead of
returning a function, returns a filter object that can be assigned
to "filter.id" or "filter.code", and behaves the same as if createFilter()
was used and the returned function used in a hook.
To make sure that the implementation of `createHookFilter()` matches
`createFilter()`, `createFilter()` now calls `createHookFilter()`
internally and uses the same object to create the test function.
Constructs a StringFilter object which can be passed to Rollup for module filtering. Provides the same filtering behavior as `createFilter()` but returns a declarative filter object instead of a function. The content of the
145
+
returned object is not guaranteed to be stable between versions.
A valid [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) pattern, or array of patterns. If `options.include` is omitted or has zero length, filter will return `true` by default. Otherwise, an ID must match one or more of the `picomatch` patterns, and must not match any of the `options.exclude` patterns.
157
+
158
+
Note that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.
159
+
160
+
#### `options`
161
+
162
+
##### `resolve`
163
+
164
+
Type: `String | Boolean | null`
165
+
166
+
Optionally resolves the patterns against a directory other than `process.cwd()`. If a `String` is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `false`, then the patterns will not be resolved against any directory. This can be useful if you want to create a filter for virtual module names.
0 commit comments