# rollup-plugin-export-equals

> Transforms export default x or export { x as default } to export = x for CommonJS module type declaration export

Latest version **0.4.0** (published 2024-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-export-equals
pnpm add rollup-plugin-export-equals
yarn add rollup-plugin-export-equals
bun add rollup-plugin-export-equals
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2024-08-22 |
| First published | 2019-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Manuel Fernandez |
| Maintainers | manferlo81 |
| Keywords | rollup, plugin, rollup-plugin, export, exports, equals |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-export-equals
- Repository: https://github.com/manferlo81/rollup-plugin-export-equals
- Homepage: https://github.com/manferlo81/rollup-plugin-export-equals#readme
- Issues: https://github.com/manferlo81/rollup-plugin-export-equals/issues
- npm.io page: https://npm.io/package/rollup-plugin-export-equals

## 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.4.0 (latest) — 2024-08-22
- 0.3.7 — 2020-10-23
- 0.3.6 — 2020-03-12
- 0.3.5 — 2019-09-14
- 0.3.4 — 2019-08-29
- 0.3.3 — 2019-07-14
- 0.3.2 — 2019-07-07
- 0.3.1 — 2019-06-30
- 0.3.0 — 2019-06-22
- 0.2.4 — 2019-06-06
- 0.2.3 — 2019-06-06
- 0.2.2 — 2019-06-01
- 0.2.1 — 2019-05-24
- 0.2.0 — 2019-05-22
- 0.1.3 — 2019-05-17
- … 6 more at https://npm.io/package/rollup-plugin-export-equals/versions

## README

# rollup-plugin-export-equals

[![CircleCI](https://circleci.com/gh/manferlo81/rollup-plugin-export-equals.svg?style=svg)](https://circleci.com/gh/manferlo81/rollup-plugin-export-equals)
[![npm](https://badgen.net/npm/v/rollup-plugin-export-equals)](https://www.npmjs.com/package/rollup-plugin-export-equals)
[![codecov](https://codecov.io/gh/manferlo81/rollup-plugin-export-equals/branch/main/graph/badge.svg)](https://codecov.io/gh/manferlo81/rollup-plugin-export-equals)
[![packagephobia](https://badgen.net/packagephobia/install/rollup-plugin-export-equals)](https://packagephobia.now.sh/result?p=rollup-plugin-export-equals)
[![bundlephobia](https://badgen.net/bundlephobia/min/rollup-plugin-export-equals)](https://bundlephobia.com/result?p=rollup-plugin-export-equals)
[![types](https://img.shields.io/npm/types/rollup-plugin-export-equals.svg)](https://github.com/microsoft/typescript)
[![Known Vulnerabilities](https://snyk.io/test/github/manferlo81/rollup-plugin-export-equals/badge.svg?targetFile=package.json)](https://snyk.io/test/github/manferlo81/rollup-plugin-export-equals?targetFile=package.json)
[![license](https://badgen.net/github/license/manferlo81/rollup-plugin-export-equals)](LICENSE)

Transforms `export default x` or `export { x as default }` to `export = x` for CommonJS module type declaration export.

> *For most applications you won't need this plugin, but it is specially useful after* [`rollup-plugin-dts`](https://github.com/Swatinem/rollup-plugin-dts) or [`rolloup-plugin-typescript2`](https://github.com/ezolenko/rollup-plugin-typescript2) *(maybe others...) if you want to build a CommonJS module.*

## Install

```bash
npm i -D rollup-plugin-export-equals
```

## Usage

### with `rollup-plugin-dts@1.x.x`

```javascript
// rollup.config.js

import dts from 'rollup-plugin-dts';
import equals from 'rollup-plugin-export-equals';

export default {

  input: 'input/index.d.ts',
  output: { file: 'out/index.d.ts', format: 'cjs' },

  plugins: [
    dts(),
    equals(),
  ],

};
```

### with `rollup-plugin-typescript2`

```javascript
// rollup.config.js

import ts from 'rollup-plugin-typescript2';
import equals from 'rollup-plugin-export-equals';

export default {

  input: 'src/index.ts',
  output: { file: 'dist/index.js', format: 'cjs' },

  plugins: [
    ts(),
    equals({
      file: 'path/to/index.d.ts'
    }),
  ],

};
```

## Options

### file

```typescript
file: string;
```

Path to the file which content to be replaced. If provided the plugin will transform the file in-place instead of the bundled output. It will process the file after it has been written to disk. For example after `rollup-plugin-typescript2` has written it to disk.

### replace

```typescript
replace: string;
replace: (match: string, captured: string) => string;
default: 'export = $1'
```

String or function to be passed to `code.replace` function. `$1` refers to the original value captured from `export default ...`.

## License

[MIT](LICENSE) &copy; 2019-2024 [Manuel Fernández](https://github.com/manferlo81)

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