{"record":{"id":"946847f8dfa3008f","repo":"vitejs/vite","slug":"invalid-rolldownoptions-input-value","errorCode":null,"errorMessage":"invalid rolldownOptions.input value.","messagePattern":"invalid rolldownOptions\\.input value\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/optimizer/scan.ts","lineNumber":244,"sourceCode":"          isEntry: true,\n          scan: true,\n        })\n      )?.id\n      if (id === undefined) {\n        throw new Error(\n          `failed to resolve rolldownOptions.input value: ${JSON.stringify(p)}.`,\n        )\n      }\n      return id\n    }\n    if (typeof input === 'string') {\n      entries = [await resolvePath(input)]\n    } else if (Array.isArray(input)) {\n      entries = await Promise.all(input.map(resolvePath))\n    } else if (isObject(input)) {\n      entries = await Promise.all(Object.values(input).map(resolvePath))\n    } else {\n      throw new Error('invalid rolldownOptions.input value.')\n    }\n  } else {\n    entries = await globEntries('**/*.html', environment)\n  }\n\n  // Non-supported entry file types and virtual files should not be scanned for\n  // dependencies.\n  entries = entries.filter(\n    (entry) =>\n      isScannable(entry, environment.config.optimizeDeps.extensions) &&\n      fs.existsSync(entry),\n  )\n\n  return entries\n}\n\nasync function prepareRolldownScanner(\n  environment: ScanEnvironment,","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/optimizer/scan.ts#L226-L262","documentation":"Thrown by `computeEntries` when `rolldownOptions.input` is set but is neither a string, an array, nor a plain object — the three shapes the resolver knows how to iterate. scan.ts:244 throws unconditionally for any other type (e.g. number, function, null after a truthy check passes).","triggerScenarios":"`build.rolldownOptions.input` (or `config.input`) is assigned a value of an unsupported type. The isObject check at scan.ts:241 passes for arrays-as-objects only via Array.isArray first; any other non-plain object (Map, function, class instance) falls through to line 244.","commonSituations":"Programmatic config that computes input dynamically and yields an unexpected type. Passing a Rollup-style `{ main: () => ... }` or a function. Misconfigured plugin that mutates input. Copy-paste from Rollup examples using unsupported shapes.","solutions":["Set `build.rolldownOptions.input` to a string, an array of strings, or a record `{ name: path }`.","Resolve dynamic input to a concrete array before returning config.","If you need code-splitting entry objects, use the `{ [name]: path }` form.","Type-check the config (`vite config` / `tsc`) to catch shape errors before run."],"exampleFix":"// before\nexport default defineConfig({\n  build: { rollupOptions: { input: () => findEntries() } }, // function unsupported\n})\n\n// after\nconst entries = await findEntries()\nexport default defineConfig({\n  build: { rollupOptions: { input: entries } }, // string[]\n})","handlingStrategy":"type-guard","validationCode":"function assertInputShape(input: unknown) {\n  if (typeof input !== 'string' && !Array.isArray(input) && (typeof input !== 'object' || input === null || Array.isArray(input) || input instanceof Map || typeof input === 'function')) {\n    throw new TypeError('rolldownOptions.input must be string, string[], or Record<string,string>')\n  }\n}","typeGuard":"function isValidInput(v: unknown): v is string | string[] | Record<string, string> {\n  if (typeof v === 'string') return true\n  if (Array.isArray(v)) return v.every((x) => typeof x === 'string')\n  if (v && typeof v === 'object' && !(v instanceof Map) && typeof v !== 'function') {\n    return Object.values(v).every((x) => typeof x === 'string')\n  }\n  return false\n}","tryCatchPattern":"try {\n  await server.listen()\n} catch (e) {\n  if (e instanceof Error && e.message === 'invalid rolldownOptions.input value.') {\n    console.error('rolldownOptions.input must be string, string[], or Record<string,string>; got', config.build.rolldownOptions.input)\n  }\n  throw e\n}","preventionTips":["Type build.rolldownOptions.input with `as string | string[] | Record<string, string>` so the compiler catches bad shapes.","Resolve dynamic input to concrete arrays before returning the config.","Add a config-validation unit test that calls your defineConfig and asserts the input shape."],"tags":["optimizer","config","input","validation"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}