rollup-plugin-auto-named-exports
raw JSON → 1.0.0-beta.3 verified Mon Apr 27 auth: no javascript maintenance
A Rollup plugin that automatically resolves named exports from CommonJS modules to avoid the 'is not exported by module' error. Version 1.0.0-beta.3. Base on rollup-plugin-commonjs, it scans modules and generates namedExports configuration automatically. Release cadence: low, beta stage. Key differentiator: eliminates manual namedExports configuration in rollup-plugin-commonjs. Alternative to manual namedExports or @rollup/plugin-commonjs namedExports. Note: tree-shaking may be affected, use with caution for production builds.
Common errors
error Error: "[name] is not exported by [module]" ↓
cause CommonJS module does not have named exports that Rollup can statically analyze
fix
Add rollup-plugin-auto-named-exports to automatically resolve named exports.
error TypeError: Cannot read properties of undefined (reading 'namedExports') ↓
cause rollup-plugin-commonjs not included or configured before autoNamedExports()
fix
Ensure commonjs() plugin is added to plugins array before autoNamedExports() as shown in quickstart.
error The plugin "auto-named-exports" does not support Rollup v3+ ↓
cause Plugin is not compatible with newer Rollup versions (v3+)
fix
Use alternative solutions like @rollup/plugin-commonjs with namedExports manually or upgrade the plugin if a newer version exists.
Warnings
breaking Tree-shaking may not work correctly ↓
fix Use manual namedExports if tree-shaking is critical; avoid this plugin in production builds where bundle size matters.
deprecated Package is based on old rollup-plugin-commonjs, not @rollup/plugin-commonjs ↓
fix Migrate to @rollup/plugin-commonjs and consider using its namedExports or other solutions.
gotcha Potential performance impact on build time ↓
fix Use only when necessary; for large projects, specifcy namedExports manually.
gotcha Beta version, may have bugs ↓
fix Test thoroughly in your environment, consider alternatives for production.
Install
npm install rollup-plugin-auto-named-exports yarn add rollup-plugin-auto-named-exports pnpm add rollup-plugin-auto-named-exports Imports
- autoNamedExports wrong
const { autoNamedExports } = require('rollup-plugin-auto-named-exports')correctimport autoNamedExports from 'rollup-plugin-auto-named-exports' - default wrong
const { default: autoNamedExports } = require('rollup-plugin-auto-named-exports')correctconst autoNamedExports = require('rollup-plugin-auto-named-exports') - Plugin types
import type { Plugin } from 'rollup'
Quickstart
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import autoNamedExports from 'rollup-plugin-auto-named-exports';
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
plugins: [
resolve(),
commonjs({
namedExports: {
// no need manual custom
}
}),
autoNamedExports()
]
};