/** * Creates a memoized lazy loader for a dynamically imported module. * * The first call triggers `import(specifier)`; subsequent calls reuse the * cached promise. This avoids re-importing the module on every invocation * while keeping the heavy module out of the synchronous startup path. */ export function createLazyModuleLoader(specifier: string): () => Promise { let cached: Promise | undefined; return (): Promise => { cached ??= import(specifier) as Promise; return cached; }; }