# unplugin-utils

> A set of utility functions commonly used by unplugins.

Latest version **0.3.2** (published 2026-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install unplugin-utils
pnpm add unplugin-utils
yarn add unplugin-utils
bun add unplugin-utils
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2026-06-29 |
| First published | 2025-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 15 |
| Author | Kevin Deng <sxzz@sxzz.moe> |
| Maintainers | sxzz |

## Links

- npm: https://www.npmjs.com/package/unplugin-utils
- Repository: https://github.com/sxzz/unplugin-utils
- Homepage: https://github.com/sxzz/unplugin-utils#readme
- Issues: https://github.com/sxzz/unplugin-utils/issues
- Funding: https://github.com/sponsors/sxzz
- npm.io page: https://npm.io/package/unplugin-utils

## Dependencies (2)

- [pathe](https://npm.io/package/pathe.md) ^2.0.3
- [picomatch](https://npm.io/package/picomatch.md) ^4.0.4

## Recent versions

- 0.3.2 (latest) — 2026-06-29
- 0.3.1 — 2025-10-06
- 0.3.0 — 2025-08-20
- 0.2.5 — 2025-08-06
- 0.2.4 — 2025-02-11
- 0.2.3 — 2025-02-05
- 0.2.2 — 2025-02-05
- 0.2.1 — 2025-02-05
- 0.2.0 — 2025-02-05
- 0.1.0 — 2025-02-05

## README

# unplugin-utils

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Unit Test][unit-test-src]][unit-test-href]
[![codecov][codecov-src]][codecov-href]

A set of utility functions commonly used by unplugins.

Thanks to [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils). This projects is heavily copied from it.

## Why Fork?

- 🌍 Platform agnostic, supports running in the browser, Node.js...
- ✂️ Subset, smaller bundle size.
- **💯 Coverage**: 100% test coverage.

## Install

```bash
npm i unplugin-utils
```

## 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

<p align="center">
  <a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
    <img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
  </a>
</p>

## License

[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)

[MIT](./LICENSE) Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/unplugin-utils.svg
[npm-version-href]: https://npmjs.com/package/unplugin-utils
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-utils
[npm-downloads-href]: https://www.npmcharts.com/compare/unplugin-utils?interval=30
[unit-test-src]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml/badge.svg
[unit-test-href]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml
[codecov-src]: https://codecov.io/gh/sxzz/unplugin-utils/graph/badge.svg?token=VDWXCPSL1O
[codecov-href]: https://codecov.io/gh/sxzz/unplugin-utils

---
_Source: https://npm.io/package/unplugin-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
