pluginPreloader.ts 533 B

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