8

Wondering if someone can clear this up for me;

I have a global component in a managed package. I want to reuse this global component outside of the managed package.

In a component outside of the package in API 41 - I could include a global component from inside a managed package and it works as expected. The global component in this case implements forceCommunity:availableForAllPageTypes,force:hasRecordId,flexipage:availableForAllPageTypes.

Component that CAN be included outside of the package:

<aura:component description="StoredAccountsManager"
                implements="forceCommunity:availableForAllPageTypes,force:hasRecordId,flexipage:availableForAllPageTypes"
                access="global"
                extends="c:BaseComponent"
                controller="StoredAccountsManagerCtrl">
    <!-- Irrelevant stuff -->
</aura:component>

BaseComponent it extends:

<aura:component description="BaseComponent" abstract="true">
    <!-- Irrelevant stuff -->
</aura:component>

Included as follows in an unmanaged component outside of the package:

<aura:component description="recpay_TPStoredAccountsMgmt" controller="recpay_TPStoredAccountsMgmtController"
    implements="flexipage:availableForAllPageTypes,force:hasRecordId,forceCommunity:availableForAllPageTypes" extends="c:recpay_BaseComponent">

    <!-- Irrelevant stuff -->

    <div class="slds-card">
        <!-- Irrelevant stuff -->
        <div class="slds-card__body">
            <aura:if isTrue="{!not(empty(v.accountId))}">
                <namespace:StoredAccountsManager
                        displayFieldSetName="{!v.displayFieldSetName}"
                        filterFieldSetName="{!v.filterFieldSetName}"
                        isHideDeleted="{!v.isHideDeleted}"
                        recordId="{!v.accountId}"
                />
                <aura:set attribute="else">
                    <small class="slds-p-around_medium">{!v.error}</small>
                </aura:set>
            </aura:if>
        </div>
    </div>

</aura:component>

Months later, I am trying to include a different global component in a similar manner, but it fails with access exceptions: Cannot read property of getDescriptor of null, and component <component being extended by global component> is not visible to markup <unmanaged component>. The global component in this case does not implement the interfaces but extends the same components as the previous example.

Global component that can't be added to an unmanaged component outside the package:

<aura:component description="CreateNewStoredAccWizard"
                controller="CreateNewStoredAccWizCtrl"
                extends="c:BaseWizard"
                access="global">
    <!-- Irrelevant Stuff -->
</aura:component>

BaseWizard it extends:

<aura:component description="BaseWizard" abstract="true" extends="c:BaseComponent">
    <!-- Irrelevant Stuff -->
</aura:component>

BaseComponent the BaseWizard extends here is the same as above.

The unmanaged component outside the package is including the component like this:

<aura:component description="recpay_StoredAccountCreationStep" extends="c:recpay_BaseWizardStep">
     <!-- Irrelevant Stuff -->
     <div class="slds-show slds-size_1-of-1 slds-grid_align-center">
            <div>
                <!-- Irrelevant Stuff -->
                <namespace:CreateNewStoredAccWizard /> <!-- Manage App here -->
                <!-- Irrelevant Stuff -->
            </div>
        </div>
    </div>
</aura:component>

I really don't want to go through the entire inheritance structure of the global component making everything global - especially as this wasn't necessary before - and doesn't seem like the real issue.

Does anyone have any insight into what the requirements are for global components being made available outside the package? Are the interfaces the key here?

  • 1
    you should throw some code snippets to make it specific so one can reproduce and see it is a bug in the code or a bug in the framework . – Mohith Shrivastava Aug 10 '18 at 20:46
  • 1
    @MohithShrivastava Good idea, I've added some code snippets. – Autonomy Aug 10 '18 at 21:00
3

Your assumption is correct, all parts of your inheritance chain need to be global, especially your abstract ones.

We use the same base approach as you since 2 years but started right away with abstract global base components so we did not experience any issues when the framework matured.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.