https://github.com/manferlo81/rollup-plugin-export-equals
Transforms export default x or export { x as default } to export = x for CommonJS module type declaration export
https://github.com/manferlo81/rollup-plugin-export-equals
equals export exports plugin plugins rollup rollup-plugin
Last synced: about 1 month ago
JSON representation
Transforms export default x or export { x as default } to export = x for CommonJS module type declaration export
- Host: GitHub
- URL: https://github.com/manferlo81/rollup-plugin-export-equals
- Owner: manferlo81
- License: mit
- Created: 2019-04-22T08:22:01.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-13T10:43:16.000Z (about 2 months ago)
- Last Synced: 2025-03-13T11:33:28.715Z (about 2 months ago)
- Topics: equals, export, exports, plugin, plugins, rollup, rollup-plugin
- Language: TypeScript
- Homepage:
- Size: 3.25 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rollup-plugin-export-equals
[](https://circleci.com/gh/manferlo81/rollup-plugin-export-equals)
[](https://www.npmjs.com/package/rollup-plugin-export-equals)
[](https://codecov.io/gh/manferlo81/rollup-plugin-export-equals)
[](https://packagephobia.now.sh/result?p=rollup-plugin-export-equals)
[](https://bundlephobia.com/result?p=rollup-plugin-export-equals)
[](https://github.com/microsoft/typescript)
[](https://snyk.io/test/github/manferlo81/rollup-plugin-export-equals?targetFile=package.json)
[](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 `[email protected]`
```javascript
// rollup.config.jsimport 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.jsimport 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) © 2019-2024 [Manuel Fernández](https://github.com/manferlo81)