unplugin-utils
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "unplugin-utils", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A set of utility functions commonly used by unplugins.", | ||
@@ -49,3 +49,3 @@ "type": "module", | ||
"engines": { | ||
"node": ">=20.18.0" | ||
"node": ">=18.12.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "prettier": "@sxzz/prettier-config", |
@@ -9,2 +9,7 @@ # unplugin-utils [![npm](https://img.shields.io/npm/v/unplugin-utils.svg)](https://npmjs.com/package/unplugin-utils) | ||
## Why Fork? | ||
- 🌍 Platform agnostic, supports running in the browser, Node.js... | ||
- ✂️ Subset, smaller bundle size. | ||
## Install | ||
@@ -16,2 +21,29 @@ | ||
## Usage | ||
### createFilter | ||
```ts | ||
export default function myPlugin(options = {}) { | ||
const filter = createFilter(options.include, options.exclude) | ||
return { | ||
transform(code, id) { | ||
if (!filter(id)) return | ||
// proceed with the transformation... | ||
}, | ||
} | ||
} | ||
``` | ||
### normalizePath | ||
```ts | ||
import { normalizePath } from 'unplugin-utils' | ||
normalizePath(String.raw`foo\bar`) // 'foo/bar' | ||
normalizePath('foo/bar') // 'foo/bar' | ||
``` | ||
## Sponsors | ||
@@ -18,0 +50,0 @@ |
12698
60