Skip to content

Commit

Permalink
chore: Absorb deleteAsync into core
Browse files Browse the repository at this point in the history
This will remove dependency warnings on downstream because dependencies
of del are outdated but del has not been updated to deal with those
dependencies.
  • Loading branch information
halostatue committed Jun 18, 2024
1 parent 72f9bbb commit ea44565
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 194 deletions.
93 changes: 37 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# @kineticcafe/rollup-plugin-delete

Delete files and folders using Rollup. This is a fork of the excellent
[rollup-plugin-delete][]. The changes are mostly:
A Rollup plugin to delete files and folders during the build process. This is
a fork of the excellent [`rollup-plugin-delete`][rpd]. The changes are:

- Convert to Typescript. The previous version produces TS2349 even though the
- Convert to Typescript. The previous version produces `TS2349` even though the
created type declaration file and the generated type declaration file are
more or less the same.

- Removing [`del`][del], which depends on outdated versions of
[`globby`][globby] and [`rimraf`][rimraf].

## About

This plugin is useful when you want to clean `dist` or other folders and files
before bundling. It's using [del][] internally, check it for pattern examples.
before bundling. Targets use [`minimatch` pattern matching][minimatch], so
review the documentation for patterns.

## Installation

Expand All @@ -27,7 +31,7 @@ npm install -D @kineticcafe/rollup-plugin-delete

## Usage

```js
```javascript
// rollup.config.js
import { del } from '@kineticcafe/rollup-plugin-delete'

Expand All @@ -41,7 +45,8 @@ export default {
}
```

You can also remove files after the bundle has been written:
You can also remove files after the bundle has been written by changing the
`hook`:

```typescript
// vite.config.ts
Expand All @@ -62,65 +67,41 @@ export default defineConfig({

### Configuration

There are some useful options:
| Name | Type | Default | Purpose |
| ------------- | ---------------------- | ------------- | -------------------------------------------------------------------------------------- |
| `targets` | `string` \| `string[]` | [] | A string or an array of patterns of files and folders to be deleted. |
| `verbose` | `boolean` | `false` | Output removed files and folders to console. Default is `false`. |
| `hook` | `string` | `buildStart` | The [Rollup hook](https://rollupjs.org/guide/en/#build-hooks) the plugin should use. |
| `runOnce` | `boolean` | `false` | Delete items once. Useful in watch mode. |
| `dryRun` | `boolean` | `false` | Does not remove the files, but reports what would be removed. Implies `verbose: true`. |
| `concurrency` | `number` | `Infinity` | Concurrency limit. Minimum `1`. |
| `cwd` | `string` | `process.cwd` | The current working directory in which to search. |

#### `targets`
All other options are inherited from `globby`, but [`expandDirectories`][ed],
[`onlyFiles`][of], and [`followSymbolicLinks`][fsl] default to `false`.

A string or an array of patterns of files and folders to be deleted. Default is
`[]`.
#### Examples

```js
```javascript
del({ targets: 'dist/*' })

del({
targets: ['dist/*', 'build/*'],
})
```

#### `verbose`

Output removed files and folders to console. Default is `false`.

```js
del({
targets: 'dist/*',
verbose: true,
})
```

> Note: use \* (wildcard character) in pattern to show removed files
#### `hook`

The [Rollup hook](https://rollupjs.org/guide/en/#build-hooks) the plugin should
use. Default is `buildStart`.

```js
del({
targets: 'dist/*',
hook: 'buildEnd',
})
```

#### `runOnce`

Type: `boolean` | Default: `false`

Delete items once. Useful in watch mode.

```js
del({
targets: 'dist/*',
runOnce: true,
})
del({ targets: ['dist/*', 'build/*'] })
del({ targets: 'dist/*', verbose: true })
del({ targets: 'dist/*', hook: 'buildEnd' })
del({ targets: 'dist/*', runOnce: true })
del({ targets: 'dist/*', dryRun: true })
```

All other options are passed to [del
package](https://github.com/sindresorhus/del) which is used inside.
> Note: use `*` (wildcard character) in the pattern to show removed files.
## License

MIT

[rollup-plugin-delete]: https://github.com/vladshcherbin/rollup-plugin-delete
[rpd]: https://github.com/vladshcherbin/rollup-plugin-delete
[del]: https://github.com/sindresorhus/del
[rimraf]: https://github.com/isaacs/rimraf
[globby]: https://github.com/sindresorhus/globby
[minimatch]: https://github.com/isaacs/minimatch#features
[ed]: https://github.com/sindresorhus/globby?tab=readme-ov-file#expanddirectories
[of]: https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#onlyfiles
[fsl]: https://github.com/mrmlnc/fast-glob?tab=readme-ov-file#followsymboliclinks
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kineticcafe/rollup-plugin-delete",
"version": "3.0.0-beta.1",
"version": "3.0.0",
"type": "module",
"contributors": [
"Vlad Shcherbin <vlad.shcherbin@gmail.com>",
Expand Down Expand Up @@ -48,16 +48,24 @@
"test": "vitest"
},
"dependencies": {
"del": "^7.1.0"
"globby": "^14.0.1",
"is-glob": "^4.0.3",
"is-path-cwd": "^3.0.0",
"is-path-inside": "^4.0.0",
"p-map": "^7.0.2",
"rimraf": "^5.0.7",
"slash": "^5.1.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.1",
"@types/fs-extra": "^11.0.4",
"@types/graceful-fs": "^4.1.9",
"@types/is-glob": "^4.0.4",
"@types/node": "20",
"@types/rollup-plugin-auto-external": "^2.0.5",
"fs-extra": "^11.2.0",
"publint": "^0.2.8",
"replace-in-file": "^7.2.0",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"rollup-plugin-auto-external": "^2.0.0",
"typescript": "^5.4.5",
Expand Down
Loading

0 comments on commit ea44565

Please sign in to comment.