{"record":{"id":"4be66b443386e4bf","repo":"vitejs/vite","slug":"either-build-lib-entry-or-the-top-level-input","errorCode":null,"errorMessage":"Either \"build.lib.entry\" or the top-level \"input\" option is required when \"build.lib\" is set.","messagePattern":"Either \"build\\.lib\\.entry\" or the top-level \"input\" option is required when \"build\\.lib\" is set\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/build.ts","lineNumber":606,"sourceCode":"    false,\n    patchConfig,\n    patchPlugins,\n  )\n}\n\nexport function resolveRolldownOptions(\n  environment: Environment,\n  chunkMetadataMap: ChunkMetadataMap,\n): RolldownOptions {\n  const { root, packageCache, base, build: options } = environment.config\n  const libOptions = options.lib\n  const { logger } = environment\n  const ssr = environment.config.consumer === 'server'\n\n  const resolve = (p: string) => path.resolve(root, p)\n  const topLevelInput = environment.config.input\n  if (libOptions && libOptions.entry == null) {\n    throw new Error(\n      `Either \"build.lib.entry\" or the top-level \"input\" option is required when \"build.lib\" is set.`,\n    )\n  }\n  const input = libOptions\n    ? options.rolldownOptions.input ||\n      (typeof libOptions.entry === 'string'\n        ? resolve(libOptions.entry)\n        : Array.isArray(libOptions.entry)\n          ? libOptions.entry.map(resolve)\n          : Object.fromEntries(\n              Object.entries(libOptions.entry!).map(([alias, file]) => [\n                alias,\n                resolve(file),\n              ]),\n            ))\n    : typeof options.ssr === 'string'\n      ? resolve(options.ssr)\n      : options.rolldownOptions.input ||","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/build.ts#L588-L624","documentation":"In `resolveRolldownOptions`, when `build.lib` is set the code requires `libOptions.entry` to be defined. If `entry` is null/undefined and there is no fallback, the build cannot know what to bundle as the library entry, so it throws instructing you to set either `build.lib.entry` or the top-level `input`.","triggerScenarios":"Configuring `build: { lib: { name: 'MyLib', formats: ['es'] } }` without an `entry` field and without a top-level `input` option, then running `vite build`.","commonSituations":"Incomplete library config copied from docs where `entry` was omitted. Building `lib` from a flag that conditionally sets `entry` and evaluates falsy. Typos like `entries` instead of `entry`.","solutions":["Add `entry` to `build.lib`: `build: { lib: { entry: 'src/index.ts', name: 'MyLib', formats: ['es'] } }`.","Alternatively set a top-level `build.rollupOptions.input` (the `input` option) when `build.lib` is set.","Double-check spelling - it's `entry`, not `entries`/`entires`."],"exampleFix":"// before\nbuild: { lib: { name: 'MyLib', formats: ['es', 'umd'] } }\n// after\nbuild: { lib: { entry: 'src/index.ts', name: 'MyLib', formats: ['es', 'umd'] } }","handlingStrategy":"validation","validationCode":"function assertLibEntryPresent(cfg: { build?: { lib?: { entry?: unknown } }; rollupOptions?: { input?: unknown } }) {\n  const lib = cfg.build?.lib\n  if (lib && lib.entry == null && cfg.rollupOptions?.input == null) {\n    throw new Error('build.lib is set but build.lib.entry and top-level input are missing')\n  }\n}","typeGuard":"function libConfigHasEntry(cfg: any): boolean {\n  return !cfg?.build?.lib || cfg.build.lib.entry != null || cfg?.rollupOptions?.input != null\n}","tryCatchPattern":null,"preventionTips":["Always set build.lib.entry when using build.lib.","Spell the field as `entry` (singular)."],"tags":["build","library-mode","config-validation","entry"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}