diff --git a/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element-with-api.function.ts b/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element-with-api.function.ts index dec2da0a65..6e775e9cf0 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element-with-api.function.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element-with-api.function.ts @@ -61,9 +61,37 @@ export async function createExtensionElementWithApi< return { element, api }; } - console.error( - `-- Extension of alias "${manifest.alias}" did not succeed creating an element with api, missing one or two JavaScript files via the 'element' and 'api' or the 'js' property or with just 'api' and the Element Name in 'elementName' in the manifest.`, - manifest, - ); + // Debug messages: + if (!element && apiConstructor) { + // If we have a elementPropValue, that means that element or js property was defined, but the element was not created. + if (elementPropValue) { + console.error( + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element with Api, Api was created but the imported Element JS file did not export a 'element' or 'default'. Alternatively define the 'elementName' in the manifest.`, + manifest, + ); + } else { + console.error( + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element with Api, Api was created but the Element was missing a JavaScript file via the 'element' or the 'js' property. Alternatively define a Element Name in 'elementName' in the manifest.`, + manifest, + ); + } + } else if (element && !apiConstructor) { + if (apiPropValue) { + console.error( + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element with Api, Element was created but the imported Api JS file did not export a 'api' or 'default'.`, + manifest, + ); + } else { + console.error( + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element with Api, Element was created but the Api is missing a JavaScript file via the 'api' or 'js' property.`, + manifest, + ); + } + } else { + console.error( + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element with Api, neither an Element or Api was created, missing one or two JavaScript files via the 'element' and 'api' or the 'js' property or with just 'api' and the Element Name in 'elementName' in the manifest.`, + manifest, + ); + } return {}; } diff --git a/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element.function.ts b/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element.function.ts index 22fe577de1..754b8ea7aa 100644 --- a/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element.function.ts +++ b/src/Umbraco.Web.UI.Client/src/libs/extension-api/functions/create-extension-element.function.ts @@ -5,25 +5,15 @@ export async function createExtensionElement( manifest: ManifestElement | ManifestElementAndApi, fallbackElement?: string, ): Promise { - if (manifest.element) { - const elementConstructor = await loadManifestElement(manifest.element); + const elementPropValue = manifest.element ?? manifest.js; + + if (elementPropValue) { + const elementConstructor = await loadManifestElement(elementPropValue); if (elementConstructor) { return new elementConstructor(); } else { console.error( - `-- Extension of alias "${manifest.alias}" did not succeed creating an element class instance via the extension manifest property 'element', using either a 'element' or 'default' export`, - manifest, - ); - } - } - - if (manifest.js) { - const elementConstructor2 = await loadManifestElement(manifest.js); - if (elementConstructor2) { - return new elementConstructor2(); - } else { - console.error( - `-- Extension of alias "${manifest.alias}" did not succeed creating an element class instance via the extension manifest property 'js', using either a 'element' or 'default' export`, + `-- Extension of alias "${manifest.alias}" did not succeed creating an element class instance via the extension manifest property '${elementPropValue}'. The imported Element JS file did not export a 'element' or 'default'. Alternatively define the 'elementName' in the manifest.`, manifest, ); } @@ -38,8 +28,9 @@ export async function createExtensionElement( } console.error( - `-- Extension of alias "${manifest.alias}" did not succeed creating an element, missing a JavaScript file via the 'element' or 'js' property or a Element Name in 'elementName' in the manifest.`, + `-- Extension of alias "${manifest.alias}" did not succeed creating an Element, missing a JavaScript file via the 'element' or 'js' property. Alternatively define a Element Name in 'elementName' in the manifest.`, manifest, ); + return undefined; }