{"id":"946847f8dfa3008f","repo":"vitejs/vite","slug":"invalid-rolldownoptions-input-value","errorCode":null,"errorMessage":"invalid rolldownOptions.input value.","messagePattern":"invalid rolldownOptions\\.input value\\.","errorType":"validation","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/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/optimizer/scan.ts#L226-L262","documentation":"A runtime type guard inside `computeEntries` that fires when `input` is neither a string, an array, nor a plain object. Vite's `rolldownOptions.input` is expected to be one of those three shapes; any other type means the config was malformed. This is essentially an exhaustiveness check that should be caught by TypeScript types but is defended at runtime.","triggerScenarios":"Passing `build.rolldownOptions.input` as a number, boolean, function, or any non-string/array/object value at runtime (e.g. via `as any` or loose JavaScript config).","commonSituations":"Config built dynamically where a variable resolved to an unexpected type, a spread that accidentally included a non-input value, or migrating from a tool whose input shape differs.","solutions":["Set `build.rolldownOptions.input` to a string, string[], or Record<string,string>.","Audit any dynamic computation producing the input value and assert its shape before assigning.","Add a TypeScript type annotation (`input: string | string[] | Record<string, string>`) to surface the error at compile time."],"exampleFix":"// before\nexport default defineConfig({\n  build: { rolldownOptions: { input: someFlag ? undefined : 0 } },\n});\n// after\nexport default defineConfig({\n  build: { rolldownOptions: { input: someFlag ? undefined : './src/main.ts' } },\n});","handlingStrategy":"type-guard","validationCode":"function assertInputShape(input) {\n  const ok =\n    typeof input === 'string' ||\n    Array.isArray(input) ||\n    (input != null && typeof input === 'object');\n  if (!ok) throw new TypeError('input must be string, array, or object');\n}\nassertInputShape(config.build.rolldownOptions?.input);","typeGuard":"function isViteInput(v) {\n  return (\n    typeof v === 'string' ||\n    Array.isArray(v) ||\n    (v != null && typeof v === 'object')\n  );\n}","tryCatchPattern":null,"preventionTips":["Never construct the input value from untyped sources without asserting its shape.","Type vite.config with `defineConfig` so the compiler rejects invalid `input` types."],"tags":["config","type-guard","entry"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}