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
In resolveBuildOutputs (build.ts:1060), UMD and IIFE formats bundle everything into a single self-contained file and therefore cannot represent multiple entry points. If libOptions.entry is an object with more than one value and the formats include 'umd' or 'iife', Vite throws.
Source
Thrown at packages/vite/src/node/build.ts:1061
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 89620f09af)
Solutions
- Restrict formats to 'es' and/or 'cjs' when you have multiple entries.
- Or reduce to a single string entry if you must output UMD/IIFE.
- Split into separate builds, one per entry, each producing its own UMD bundle.
Example fix
// before
build: { lib: { entry: { a: 'src/a.ts', b: 'src/b.ts' }, formats: ['es', 'umd'] } }
// after
build: { lib: { entry: { a: 'src/a.ts', b: 'src/b.ts' }, formats: ['es', 'cjs'] } } Defensive patterns
Strategy: validation
Validate before calling
const lib = config.build?.lib
const multi = lib && typeof lib.entry !== 'string' && lib.entry && Object.values(lib.entry).length > 1
const fmts = lib?.formats ?? (multi ? ['es', 'cjs'] : ['es', 'umd'])
if (multi && (fmts.includes('umd') || fmts.includes('iife'))) {
throw new Error('Multiple entries cannot use umd/iife formats')
} Type guard
function isSingleEntry(lib: any): boolean {
return typeof lib.entry === 'string' ||
(lib.entry && Object.values(lib.entry).length <= 1)
} Prevention
- For multi-entry libraries, restrict formats to es/cjs.
- Run a separate build per entry if UMD is required.
- Remember UMD/IIFE produce a single file and inherently cannot split entries.
When it happens
Trigger: Configuring build.lib with an object entry map of 2+ entries and formats containing 'umd' or 'iife' (or relying on the default formats which include 'umd' for single, but for multi default to es/cjs).
Common situations: Multi-entry library configs where someone adds 'umd' to formats; expecting UMD output for each entry.
Related errors
- Entries in "build.rolldownOptions.output" must specify "name
- Name in package.json is required if option "build.lib.fileNa
- Option "build.lib.name" is required when output formats incl
- Either "build.lib.entry" or the top-level "input" option is
- Vite does not support "rolldownOptions.output.file". Please
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/01ffd8cdffca89cd.json.
Report an issue: GitHub.