# @toolbuilder/rollup-plugin-create-pack-file

> Rollup plugin to create a pack file and move it somewhere else for testing.

Latest version **0.1.7** (published 2024-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @toolbuilder/rollup-plugin-create-pack-file
pnpm add @toolbuilder/rollup-plugin-create-pack-file
yarn add @toolbuilder/rollup-plugin-create-pack-file
bun add @toolbuilder/rollup-plugin-create-pack-file
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2024-11-07 |
| First published | 2020-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | toolbuilder |
| Keywords | rollup, plugin, rollup-plugin, pack |

## Links

- npm: https://www.npmjs.com/package/@toolbuilder/rollup-plugin-create-pack-file
- Repository: https://github.com/toolbuilder/rollup-plugin-create-pack-file
- Homepage: https://github.com/toolbuilder/rollup-plugin-create-pack-file#readme
- Issues: https://github.com/toolbuilder/rollup-plugin-create-pack-file/issues
- npm.io page: https://npm.io/package/@toolbuilder/rollup-plugin-create-pack-file

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) 5.1.1
- [pkg-dir](https://npm.io/package/pkg-dir.md) 5.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.2.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.1.7 (latest) — 2024-11-07
- 0.1.6 — 2023-08-04
- 0.1.5 — 2023-08-02
- 0.1.4 — 2021-07-19
- 0.1.3 — 2020-07-20
- 0.1.2 — 2020-06-29
- 0.1.1 — 2020-06-07

## README

# Rollup-Plugin-Create-Pack-File

This [Rollup](https://rollupjs.org/guide/en/) plugin creates a pack file from your package, and moves it somewhere else as part of testing your package.

This plugin is used by [@toolbuilder/rollup-plugin-test-tools](https://github.com/toolbuilder/rollup-plugin-test-tools), which tests your [pack file](https://docs.npmjs.com/cli/v6/commands/npm-pack) in temporary ES, CommonJS, and Electron projects.

## Installation

```bash
npm install --save-dev @toolbuilder/rollup-plugin-create-pack-file
```

## Use

```javascript
import createPackFile from '@toolbuilder/rollup-plugin-create-pack-file'

export default {
  input: 'entry-point.js',
  output: {
    // By default the plugin will use output.dir or dirname(output.file) for the output directory
    file: 'somewhere/es/entry-point.js'
    format: 'es'
  },
  plugins: [
    createPackFile({
      // if you want the packfile in another place than dirname(output.file) or output.dir,
      // specify that directory here.
      outputDir: 'somewhere'
    })
  ]
}
```

This plugin runs using the `generateBundle` hook. This lets you use the pack file when the `writeBundle` hook runs. The `writeBundle` hook runs plugins in parallel, so you can't control plugin execution order.

## Options

There are a number of options. The advanced options exist for unit testing, but you might find them useful.

Basic Options:

* `rootDir` - tell the plugin where the package root is located. By default, this is `process.cwd()`.
* `outputDir` - tell the plugin the output directory for the pack file. By default the plugin uses Rollup options `output.dir` or `dirname(output.file)` - whichever was specified.
* `packCommand` - tell the plugin what command to use to generate the pack file. This is not run in a shell, but `execa` is used to parse the command. By default, this is `npm pack`. For example, I use [pnpm](https://pnpm.js.org/) instead of `npm`, so my packCommand option looks like `pnpm pack`. The plugin expects the pack file name to match `npm` naming conventions.

Advanced options:

* `packageJson` - By default, the plugin reads `package.json` at `rootDir` to figure out the pack file name. If you want something else, provide this option an Object that has `name` and `version` attributes just like `package.json` does.
* `mover` - Async method that moves the pack file. Signature looks like this: async (fullPackFilePath, fullTargetPackFilePath) => {}. No return value is expected. An `Error` should be thrown on failure. By default the plugin provides a function to move the file.
* `shellCommand` - An async method that creates the pack file when given the `packCommand` option value. No return value is expected, an `Error` should be thrown on failure. By default, the plugin uses `execa.command` to run `packCommand`.

## Contributing

Contributions are welcome. Please create a pull request.

I use [pnpm](https://pnpm.js.org/) instead of npm.

## Issues

This project uses Github issues.

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