```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")) {
    // Ignore blank lines and comments
    if (!line.trim() || line.startsWith("#")) continue;

    // Split on the first '=' only
    const [key, value] = line.split("=", 2);
    
    // Trim whitespace around key and value
    const trimmedKey = key.trim();
    const trimmedValue = value ? value.trim() : "";

    // Throw an error if there's no '=' or an empty key
    if (!trimmedKey || !trimmedValue.includes("=")) {
      throw new Error(`Invalid line: ${line}`);
    }

    // Ignore __proto__ to avoid prototype pollution
    if (trimmedKey === "__proto__") continue;

    config[trimmedKey] = trimmedValue;
  }
  return config;
}
```