vitejs/vite · error · Error
Multiple entry points are not supported when output formats…
Error message
Multiple entry points are not supported when output formats include "umd" or "iife".
What it means
UMD and IIFE formats produce a single self-executing bundle with one global variable, so they cannot represent multiple entry points. resolveBuildOutputs throws when lib.formats includes 'umd' or 'iife', the output is not already an array, and the lib.entry object has more than one key.
Solutions
- Restrict lib.formats to multi-entry-friendly formats: ['es', 'cjs'].
- Keep only one entry when you must emit umd/iife (split the multi-entry build from the umd build).
- If you need umd for several entries, run multiple Vite builds with a different single entry each.
Example fix
// before
build: {
lib: { entry: { main: 'src/main.ts', ui: 'src/ui.ts' }, formats: ['es', 'umd'] }
}
// after
build: {
lib: { entry: { main: 'src/main.ts', ui: 'src/ui.ts' }, formats: ['es', 'cjs'] }
} Defensive patterns
Strategy: validation
Validate before calling
function checkLibFormats(libOptions) {
if (!libOptions) return null;
const multi = typeof libOptions.entry === 'object' && libOptions.entry && Object.keys(libOptions.entry).length > 1;
const formats = libOptions.formats || (multi ? ['es', 'cjs'] : ['es', 'umd']);
if (multi && (formats.includes('umd') || formats.includes('iife'))) {
return 'Multiple entries cannot use umd/iife formats';
}
return null;
} Type guard
function libSupportsUmdIife(libOptions) {
const multi = typeof libOptions?.entry === 'object' && Object.keys(libOptions.entry || {}).length <= 1;
return multi;
} Prevention
- Reserve umd/iife for single-entry library builds.
- Switch multi-entry libs to ['es', 'cjs'].
When it happens
Trigger: Configuring build.lib.entry as an object with 2+ entries (e.g. { main: 'src/main.ts', ui: 'src/ui.ts' }) while build.lib.formats contains 'umd' or 'iife'.
Common situations: Multi-entry component libraries that default formats to include umd for script-tag consumption; copy-pasting a single-entry umd config and then adding more entries.
Related errors
- Option "build.lib.name" is required when output formats…
- Name in package.json is required if option…
- Environment " " is not defined in the config.
- `input` cannot contain glob characters. They are reserved…
- Name in package.json is required if option…
AI-assisted analysis of vitejs/vite@b4d66fee14 (2026-08-11).
Data as JSON: /api/errors/01ffd8cdffca89cd.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vite/src/node/build.ts:1065
export function resolveBuildOutputs(
outputs: OutputOptions | OutputOptions[] | undefined,
libOptions: LibraryOptions | false,
logger: Logger,
): OutputOptions | OutputOptions[] | undefined {
if (libOptions) {
const libHasMultipleEntries =
typeof libOptions.entry !== 'string' &&
libOptions.entry &&
Object.values(libOptions.entry).length > 1
const libFormats =
libOptions.formats ||
(libHasMultipleEntries ? ['es', 'cjs'] : ['es', 'umd'])
if (!Array.isArray(outputs)) {
if (libFormats.includes('umd') || libFormats.includes('iife')) {
if (libHasMultipleEntries) {
throw new Error(
'Multiple entry points are not supported when output formats include "umd" or "iife".',
)
}
if (!libOptions.name) {
throw new Error(
'Option "build.lib.name" is required when output formats include "umd" or "iife".',
)
}
}
return libFormats.map((format) => ({ ...outputs, format }))
}
// By this point, we know "outputs" is an Array.
if (libOptions.formats) {
logger.warn(
colors.yellow(View on GitHub (pinned to b4d66fee14)