Transforms export default x or export { x as default } to export = x for CommonJS module type declaration export
npm install rollup-plugin-export-equals







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 or rolloup-plugin-typescript2 (maybe others...) if you want to build a CommonJS module.
``bash`
npm i -D rollup-plugin-export-equals
`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(),
],
};
`
`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'
}),
],
};
`
`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.
`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 ...`.
MIT © 2019-2024 Manuel Fernández