also looking at this
fix: browser-safe config loading and correct dual-theme token colors
#477
6 files
+237
-21
| @@ -1,5 +1,4 @@ | ||
| 1 | 1 | import type { SyntaxHighlighterConfig } from './types' |
| 2 | import { loadConfig } from 'bunfig' | |
| 3 | 2 | |
| 4 | 3 | export const defaultConfig: SyntaxHighlighterConfig = { |
| 5 | 4 | verbose: false, |
| @@ -14,6 +13,13 @@ let _config: SyntaxHighlighterConfig | null = null | ||
| 14 | 13 | |
| 15 | 14 | export async function loadSyntaxHighlighterConfig(): Promise<SyntaxHighlighterConfig> { |
| 16 | 15 | if (!_config) { |
| 16 | // `bunfig` reads config files from disk and is Node/Bun-only, so it is | |
| 17 | // imported dynamically here rather than at module scope. A static | |
| 18 | // top-level import would drag its own eager, unguarded `process.env` | |
| 19 | // access into every consumer's bundle purely by importing this | |
| 20 | // package's index, crashing immediately in a browser even for callers | |
| 21 | // who never touch config loading. | |
| 22 | const { loadConfig } = await import('bunfig') | |
| 17 | 23 | _config = await loadConfig({ |
| 18 | 24 | name: 'syntax', |
| 19 | 25 | defaultConfig, |