```ts
/** The KEY=VALUE pairs of a config file. */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    // Trim leading and trailing whitespace from the line
    const trimmedLine = line.trim();
    if (trimmedLine.length === 0) continue; // Skip blank lines
    if (trimmedLine.startsWith("#")) continue; // Skip commented lines

    const [key, value] = trimmedLine.split("=", 2);
    if (!key || key.trim() === "") {
      throw new Error(`Empty or invalid key on line: "${line}"`);
    }
    config[key.trim()] = value !== undefined ? value.trim() : "";
  }
  return config;
}
```