| 134 | |
| 135 | // Import the resolved module only after all earlier validation has succeeded. |
| 136 | export async function load(row: Resolved): Promise<{ ok: true; value: Loaded } | { ok: false; error: unknown }> { |
| 137 | let mod |
| 138 | try { |
| 139 | mod = await import(row.entry) |
| 140 | } catch (error) { |
| 141 | return { ok: false, error } |
| 142 | } |
| 143 | if (!mod) return { ok: false, error: new Error(`Plugin ${row.spec} module is empty`) } |
| 144 | return { ok: true, value: { ...row, mod } } |
| 145 | } |
| 146 | |
| 147 | // Run one candidate through the full pipeline: resolve, optionally surface a missing entry, |
| 148 | // import the module, and finally let the caller transform the loaded plugin into any result type. |