# @start/plugin

> ⚙️ Plugin creator

Latest version **2.0.0** (published 2020-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @start/plugin
pnpm add @start/plugin
yarn add @start/plugin
bun add @start/plugin
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2020-08-14 |
| First published | 2018-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.13.0 |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 472 |
| Author | Kir Belevich |
| Maintainers | deepsweet, fosimus, psxcode, xaviervia |
| Keywords | tasks, runner, start, start-plugin |

## Links

- npm: https://www.npmjs.com/package/@start/plugin
- Repository: https://github.com/deepsweet/start
- Homepage: https://github.com/deepsweet/start#readme
- Issues: https://github.com/deepsweet/start/issues
- npm.io page: https://npm.io/package/@start/plugin

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2020-08-14
- 1.0.0 — 2020-01-23
- 0.3.1 — 2019-04-01
- 0.3.0 — 2019-02-06
- 0.2.1 — 2018-09-13
- 0.2.0 — 2018-06-21
- 0.1.0 — 2018-05-14
- 0.1.0-5 — 2018-04-28
- 0.1.0-4 — 2018-04-28
- 0.1.0-3 — 2018-04-20
- 0.1.0-2 — 2018-04-20
- 0.1.0-1 — 2018-04-12

## README

# ⚙️ plugin

Plugin creator.

## Install

```sh
$ yarn add @start/plugin
```

## Usage

### Types

See [`src/index.ts`](src/index.ts) for all the types. It's (usually) better than any words.

### Example

```js
import plugin from '@start/plugin'

export default plugin('noop', () => () => {})
```

```js
import plugin from '@start/plugin'

export default plugin('foo', ({ logPath }) => async ({ files }) => {
  const { default: fooTransform } = await import('foo-lib')

  return {
    files: await Promise.all(
      files.map(async (file) =>
        const { transformedData, sourceMap } = fooTransform(file.path)

        logPath(file.path)

        return {
          path: file.path,
          data: transformedData,
          map: sourceMap
        }
      )
    )
  }
})
```

```js
import plugin from '@start/plugin'

export default (barOptions) =>
  plugin('bar', ({ logMessage }) => async () => {
    const { default: barCheck } = await import('bar-lib')

    const barResult = barCheck(files, barOptions)

    if (barResult.issues.length === 0) {
      logMessage('¯\\_(ツ)_/¯')
    }
  })
```

## Notes

* Dynamic imports – [it's a good idea](https://github.com/gulpjs/gulp/issues/632) to "lazyload" dependencies inside of a plugin function instead of importing it on top of a file
* Plugin can return whatever "props" object or just nothing, and that output will extend an input props as an overall plugin result
* `files` – many plugins works with `files` structure: it's an array of `{ path, data, map }` objects, where:
  * `path` – absolute file path
  * `data` – file data as utf8 string, if any
  * `map` – [Source Map object](https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-anatomy), if any
* `logMessage` – any random message from plugin
* `logPath` – current file path to indicate some kind of progress
* `reporter` – advanced prop which should be passed through if plugin operates other plugins, like [sequence](../plugin-sequence) or [watch](../plugin-watch)

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