{"id":"01ffd8cdffca89cd","repo":"vitejs/vite","slug":"multiple-entry-points-are-not-supported-when-outpu","errorCode":null,"errorMessage":"Multiple entry points are not supported when output formats include \"umd\" or \"iife\".","messagePattern":"Multiple entry points are not supported when output formats include \"umd\" or \"iife\"\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/build.ts","lineNumber":1061,"sourceCode":"\nexport function resolveBuildOutputs(\n  outputs: OutputOptions | OutputOptions[] | undefined,\n  libOptions: LibraryOptions | false,\n  logger: Logger,\n): OutputOptions | OutputOptions[] | undefined {\n  if (libOptions) {\n    const libHasMultipleEntries =\n      typeof libOptions.entry !== 'string' &&\n      libOptions.entry &&\n      Object.values(libOptions.entry).length > 1\n    const libFormats =\n      libOptions.formats ||\n      (libHasMultipleEntries ? ['es', 'cjs'] : ['es', 'umd'])\n\n    if (!Array.isArray(outputs)) {\n      if (libFormats.includes('umd') || libFormats.includes('iife')) {\n        if (libHasMultipleEntries) {\n          throw new Error(\n            'Multiple entry points are not supported when output formats include \"umd\" or \"iife\".',\n          )\n        }\n\n        if (!libOptions.name) {\n          throw new Error(\n            'Option \"build.lib.name\" is required when output formats include \"umd\" or \"iife\".',\n          )\n        }\n      }\n\n      return libFormats.map((format) => ({ ...outputs, format }))\n    }\n\n    // By this point, we know \"outputs\" is an Array.\n    if (libOptions.formats) {\n      logger.warn(\n        colors.yellow(","sourceCodeStart":1043,"sourceCodeEnd":1079,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/build.ts#L1043-L1079","documentation":"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.","triggerScenarios":"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).","commonSituations":"Multi-entry library configs where someone adds 'umd' to formats; expecting UMD output for each entry.","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."],"exampleFix":"// before\nbuild: { lib: { entry: { a: 'src/a.ts', b: 'src/b.ts' }, formats: ['es', 'umd'] } }\n// after\nbuild: { lib: { entry: { a: 'src/a.ts', b: 'src/b.ts' }, formats: ['es', 'cjs'] } }","handlingStrategy":"validation","validationCode":"const lib = config.build?.lib\nconst multi = lib && typeof lib.entry !== 'string' && lib.entry && Object.values(lib.entry).length > 1\nconst fmts = lib?.formats ?? (multi ? ['es', 'cjs'] : ['es', 'umd'])\nif (multi && (fmts.includes('umd') || fmts.includes('iife'))) {\n  throw new Error('Multiple entries cannot use umd/iife formats')\n}","typeGuard":"function isSingleEntry(lib: any): boolean {\n  return typeof lib.entry === 'string' ||\n    (lib.entry && Object.values(lib.entry).length <= 1)\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["build","library-mode","umd","output"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}