rollup-plugin-aggregate-exports
Emit an entry file to aggregate exports across multiple files.
If you like this project, please star it & follow me to see what other cool projects I'm working on!
🚀 Install
npm i -D rollup-plugin-aggregate-exports
🚦 Quick Setup
import aggregateExports from 'rollup-plugin-aggregate-exports';
const rollupConfig = {
input: 'src/file.js',
plugins: [
aggregateExports({
// file name for the entry file
fileName: 'index.js',
// export statements
exports: [
{
identifier: 'default',
as: 'entry',
from: './entry.js',
},
{
identifier: 'default',
as: 'chunk',
from: './chunk.js',
},
],
}),
],
output: {
format: 'esm',
file: 'dist/entry.js',
exports: 'default',
},
};
export default rollupConfig;
⚙️ API
interface Export {
/**
* Path to import from
*/
from: string;
/**
* Identifier to imort
*/
identifier: string;
/**
* Name to export as
*/
as?: string;
}
aggregateExports(options?: {
/**
* The file name to use for the emitted entry file.
*
* @defaultValue `index.js`
*/
fileName?: string;
/**
* The exports you want to aggregate.
*
* @defaultValue `[]`
*/
exports?: (string | Export)[];
});