# rollup-preserve-directives

> Rollup plugin to preserve directives

Latest version **1.1.3** (published 2024-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-preserve-directives
pnpm add rollup-preserve-directives
yarn add rollup-preserve-directives
bun add rollup-preserve-directives
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2024-11-24 |
| First published | 2023-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | huozhi |
| Maintainers | huozhi, sukkaw |
| Keywords | rollup, plugin, preserve, directives |

## Links

- npm: https://www.npmjs.com/package/rollup-preserve-directives
- Repository: https://github.com/huozhi/rollup-preserve-directives
- Homepage: https://github.com/huozhi/rollup-preserve-directives#readme
- Issues: https://github.com/huozhi/rollup-preserve-directives/issues
- npm.io page: https://npm.io/package/rollup-preserve-directives

## Dependencies (1)

- [magic-string](https://npm.io/package/magic-string.md) ^0.30.5

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2024-11-24
- 1.1.2 — 2024-10-05
- 1.1.1 — 2023-12-28
- 1.1.0 — 2023-12-17
- 1.0.1 — 2023-12-08
- 1.0.0 — 2023-11-27
- 0.0.0 — 2023-07-09

## README

# rollup-preserve-directives

A rollup plugin helps preserving shebang and string directives in your code.

## Install

```bash
npm install rollup-preserve-directives
```

## Usage

```js
import preserveDirectives from 'rollup-preserve-directives'

export default {
  input: './src/index.js',
  output: {
    file: './dist/index.js',
    format: 'cjs'
  },
  plugins: [
    preserveDirectives()
  ]
}
```

### Inter-plugin-communication

This plugin exposes the result of its directives information of current file for other plugins to use. You can access it via `this.getModuleInfo` or the `moduleParsed` hook.

```ts
// `meta` property info
{
  preserveDirectives: {
    directives: string[]
    shebang: string
  }
}
```

## License

MIT

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