fix(plugin-tools): load lazy plugins with default exports correctly

This commit is contained in:
Joakim Carlstein 2023-11-22 15:35:30 +01:00
parent c68c6f0490
commit 60ae3b8c82
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'@emigrate/plugin-tools': patch
---
Fix loading of lazy loaded plugins with default exports

View file

@ -101,6 +101,12 @@ export const getOrLoadPlugins = async <T extends PluginType>(
continue; continue;
} }
// Support export default ...
if (plugin && typeof plugin === 'object' && 'default' in plugin && isPluginOfType(type, plugin.default)) {
result.push(plugin.default);
continue;
}
const loadedPlugin = typeof plugin === 'string' ? await loadPlugin(type, plugin) : undefined; const loadedPlugin = typeof plugin === 'string' ? await loadPlugin(type, plugin) : undefined;
if (loadedPlugin) { if (loadedPlugin) {