(modulePath, config)
| 692 | } |
| 693 | |
| 694 | async function loadPluginAsync(modulePath, config) { |
| 695 | let pluginMod |
| 696 | try { |
| 697 | // Try dynamic import first (works for both ESM and CJS) |
| 698 | const resolvedPath = resolveImportModulePath(modulePath) |
| 699 | pluginMod = await import(resolvedPath) |
| 700 | } catch (err) { |
| 701 | throw new Error(`Could not load plugin from '${modulePath}': ${err.message}`) |
| 702 | } |
| 703 | |
| 704 | const pluginFactory = pluginMod.default || pluginMod |
| 705 | if (typeof pluginFactory !== 'function') { |
| 706 | throw new Error(`Plugin '${modulePath}' is not a function. Expected a plugin factory function.`) |
| 707 | } |
| 708 | |
| 709 | return pluginFactory(config) |
| 710 | } |
| 711 | |
| 712 | async function loadPluginFallback(modulePath, config) { |
| 713 | // This function is kept for backwards compatibility but now uses dynamic import |
no test coverage detected