```typescript
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  /**
   * Parse a config file into a plain object.
   *
   * Ignores blank lines and lines starting with '#', trims whitespace around keys
   * and values, splits on the first '=' character to allow for single-value lines,
   * throws an Error if a line is missing a key or has an empty value.
   */
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (!line.trim() || line.startsWith('#')) continue;
    const [key, value] = line.split('=', 2);
    if (!key) throw new Error(`Missing key on line ${line}`);
    if (!value.trim()) throw new Error(`Empty value on line ${line}`);
    config[key.trim()] = value.trim();
  }
  return config;
}
```