A set of utility functions commonly used by unplugins.
npm install 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. This projects is heavily copied from it.
- 🌍 Platform agnostic, supports running in the browser, Node.js...
- ✂️ Subset, smaller bundle size.
- 💯 Coverage: 100% test coverage.
``bash`
npm i unplugin-utils
`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...
},
}
}
`
`ts
import { normalizePath } from 'unplugin-utils'
normalizePath(String.rawfoo\bar) // 'foo/bar'``
normalizePath('foo/bar') // 'foo/bar'
MIT License © 2025-PRESENT Kevin Deng
MIT Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
[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