vitejs/vite · error · Error

invalid rolldownOptions.input value.

Error message

invalid rolldownOptions.input value.

What it means

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.

Source

Thrown at packages/vite/src/node/optimizer/scan.ts:244

          isEntry: true,
          scan: true,
        })
      )?.id
      if (id === undefined) {
        throw new Error(
          `failed to resolve rolldownOptions.input value: ${JSON.stringify(p)}.`,
        )
      }
      return id
    }
    if (typeof input === 'string') {
      entries = [await resolvePath(input)]
    } else if (Array.isArray(input)) {
      entries = await Promise.all(input.map(resolvePath))
    } else if (isObject(input)) {
      entries = await Promise.all(Object.values(input).map(resolvePath))
    } else {
      throw new Error('invalid rolldownOptions.input value.')
    }
  } else {
    entries = await globEntries('**/*.html', environment)
  }

  // Non-supported entry file types and virtual files should not be scanned for
  // dependencies.
  entries = entries.filter(
    (entry) =>
      isScannable(entry, environment.config.optimizeDeps.extensions) &&
      fs.existsSync(entry),
  )

  return entries
}

async function prepareRolldownScanner(
  environment: ScanEnvironment,

View on GitHub (pinned to 89620f09af)

Solutions

  1. Set `build.rolldownOptions.input` to a string, string[], or Record<string,string>.
  2. Audit any dynamic computation producing the input value and assert its shape before assigning.
  3. Add a TypeScript type annotation (`input: string | string[] | Record<string, string>`) to surface the error at compile time.

Example fix

// before
export default defineConfig({
  build: { rolldownOptions: { input: someFlag ? undefined : 0 } },
});
// after
export default defineConfig({
  build: { rolldownOptions: { input: someFlag ? undefined : './src/main.ts' } },
});
Defensive patterns

Strategy: type-guard

Validate before calling

function assertInputShape(input) {
  const ok =
    typeof input === 'string' ||
    Array.isArray(input) ||
    (input != null && typeof input === 'object');
  if (!ok) throw new TypeError('input must be string, array, or object');
}
assertInputShape(config.build.rolldownOptions?.input);

Type guard

function isViteInput(v) {
  return (
    typeof v === 'string' ||
    Array.isArray(v) ||
    (v != null && typeof v === 'object')
  );
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03). Data as JSON: /data/errors/946847f8dfa3008f.json. Report an issue: GitHub.