From 60ae3b8c82bc42e71bf5025d36281f87f6f23035 Mon Sep 17 00:00:00 2001 From: Joakim Carlstein Date: Wed, 22 Nov 2023 15:35:30 +0100 Subject: [PATCH] fix(plugin-tools): load lazy plugins with default exports correctly --- .changeset/large-berries-marry.md | 5 +++++ packages/plugin-tools/src/index.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/large-berries-marry.md diff --git a/.changeset/large-berries-marry.md b/.changeset/large-berries-marry.md new file mode 100644 index 0000000..0be0d3d --- /dev/null +++ b/.changeset/large-berries-marry.md @@ -0,0 +1,5 @@ +--- +'@emigrate/plugin-tools': patch +--- + +Fix loading of lazy loaded plugins with default exports diff --git a/packages/plugin-tools/src/index.ts b/packages/plugin-tools/src/index.ts index 0ba58fe..10479e6 100644 --- a/packages/plugin-tools/src/index.ts +++ b/packages/plugin-tools/src/index.ts @@ -101,6 +101,12 @@ export const getOrLoadPlugins = async ( 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; if (loadedPlugin) {