first commit
This commit is contained in:
25
node_modules/@rolldown/pluginutils/LICENSE
generated
vendored
Normal file
25
node_modules/@rolldown/pluginutils/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024-present VoidZero Inc. & Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
end of terms and conditions
|
||||
|
||||
The licenses of externally maintained libraries from which parts of the Software is derived are listed [here](https://github.com/rolldown/rolldown/blob/main/THIRD-PARTY-LICENSE).
|
||||
83
node_modules/@rolldown/pluginutils/README.md
generated
vendored
Normal file
83
node_modules/@rolldown/pluginutils/README.md
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
# @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
|
||||
|
||||
```sh
|
||||
pnpm add @rolldown/pluginutils
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Simple Filters
|
||||
|
||||
```ts
|
||||
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 or unplugin. They can be used in Rolldown plugins only.
|
||||
|
||||
```ts
|
||||
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. A `string` pattern is matched by exact equality (not glob); a `RegExp` is tested against the id.
|
||||
- `importerId(pattern, params?)` — Filter by importer id. A `string` pattern is matched by exact equality; a `RegExp` is tested against the importer id. Only usable with the `resolveId` hook.
|
||||
- `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.
|
||||
|
||||
### Utilities
|
||||
|
||||
- `filterVitePlugins(plugins)` — Filters out Vite plugins with `apply: 'serve'`.
|
||||
37
node_modules/@rolldown/pluginutils/package.json
generated
vendored
Normal file
37
node_modules/@rolldown/pluginutils/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@rolldown/pluginutils",
|
||||
"version": "1.0.0-rc.12",
|
||||
"homepage": "https://rolldown.rs/",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rolldown/rolldown.git",
|
||||
"directory": "packages/pluginutils"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./filter": "./dist/filter/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/picomatch": "^4.0.0",
|
||||
"picomatch": "^4.0.2",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^4.0.15"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "vitest --typecheck",
|
||||
"publint": "publint ."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user