1import { PreloadPlugin } from '@grafana/data'; 2import { importPluginModule } from './plugin_loader'; 3 4export async function preloadPlugins(pluginsToPreload: PreloadPlugin[] = []): Promise<void> { 5 await Promise.all(pluginsToPreload.map(preloadPlugin)); 6} 7 8async function preloadPlugin(plugin: PreloadPlugin): Promise<void> { 9 const { path, version } = plugin; 10 try { 11 await importPluginModule(path, version); 12 } catch (error: unknown) { 13 console.error(`Failed to load plugin: ${path} (version: ${version})`, error); 14 } 15} 16