# @thunderal/rollup-preprocess-plugin

> Rollup plugin to make build-time generated modules

Latest version **0.0.2** (published 2023-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @thunderal/rollup-preprocess-plugin
pnpm add @thunderal/rollup-preprocess-plugin
yarn add @thunderal/rollup-preprocess-plugin
bun add @thunderal/rollup-preprocess-plugin
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-01-23 |
| First published | 2023-01-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=14.0.0 |
| Dependencies | 1 |
| Unpacked size | 5.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | ThunderAl |
| Maintainers | thunderal |
| Keywords | rollup, plugin, preprocess, modules |

## Links

- npm: https://www.npmjs.com/package/@thunderal/rollup-preprocess-plugin
- npm.io page: https://npm.io/package/@thunderal/rollup-preprocess-plugin

## Dependencies (1)

- [@rollup/pluginutils](https://npm.io/package/@rollup/pluginutils.md) ^5.0.0

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

- 0.0.2 (latest) — 2023-01-23

## README

# @thunderal/rollup-preprocess-plugin

A Rollup plugin which allows you to tun build time code and include it's result to output bundle

## Requirements

This plugin requires an LTS Node version (v14.0.0+) and Rollup v2.0.0+.

## Install

Using npm:

```shell
npm install --save-dev @thunderal/rollup-preprocess-plugin
```

Using yarn:

```shell
yarn add -D @thunderal/rollup-preprocess-plugin
```

## Usage

1. Create a `rollup.config.js` and import the plugin:
    ```js
    import preprocess from '@thunderal/rollup-preprocess-plugin'
    
    const bundle = await rollup.rollup({
      input: 'src/index.js',
      plugins: [
        preprocess(),
      ],
    })
    ```

2. Create preprocessing file (ex `hash-output.preprocess.mjs`):
   ```js
   import crypto from 'node:crypto'
   
   export default async function () {   
     const hash = crypto.createHash('sha512')
       .update('super secret string. will not appear in result bundle')
       .digest()
       .toString('hex')
     
     return `export const myHash = '${hash}';`
   }
   ```

3. Import generator file from another module (ex `index.mjs`):
   ```js
   import {myHash} from 'hash-output.preprocess.mjs'
   
   console.log(myHash)
   ```
   
4. Run rollup. Output will be:
   ```js
   const myHash = "66631b816a5f33d6f...";
   
   console.log(myHash)
   ```

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