diff --git a/plugins/app/src/extensions/SwappableComponentsApi.ts b/plugins/app/src/extensions/SwappableComponentsApi.ts index c969cbb057..c848b0a575 100644 --- a/plugins/app/src/extensions/SwappableComponentsApi.ts +++ b/plugins/app/src/extensions/SwappableComponentsApi.ts @@ -37,18 +37,32 @@ export const SwappableComponentsApi = ApiBlueprint.makeWithOverrides({ defineParams({ api: swappableComponentsApiRef, deps: {}, - factory: () => - DefaultSwappableComponentsApi.fromComponents( - inputs.components.map(i => { - if (i.node.spec.plugin?.id !== 'app') { - // eslint-disable-next-line no-console - console.warn( - `SwappableComponents should only be installed as an extension in the app plugin. You can either use appPlugin.override(), or provide a module for the app-plugin with the extension there instead. id={${i.node.spec.id}}`, - ); - } - return i.get(SwappableComponentBlueprint.dataRefs.component); - }), - ), + factory: () => { + const nonAppExtensions = inputs.components.filter( + i => i.node.spec.plugin?.id !== 'app', + ); + + if (nonAppExtensions.length > 0) { + // eslint-disable-next-line no-console + console.warn( + `SwappableComponents should only be installed as an extension in the app plugin. + You can either use appPlugin.override(), or provide a module for the app-plugin with the extension there instead. + Invalid extensions: ${nonAppExtensions + .map(i => i.node.spec.id) + .join(', ')}`, + ); + } + + const appExtensions = inputs.components.filter( + i => i.node.spec.plugin?.id === 'app', + ); + + return DefaultSwappableComponentsApi.fromComponents( + appExtensions.map(i => + i.get(SwappableComponentBlueprint.dataRefs.component), + ), + ); + }, }), ); },