4

I have an LWC component as part of a managed package. To support Classic its also embedded inside VF page using a Lightning App(Aura):

<apex:page standardcontroller="Account">

    <apex:includeLightning/>
    <div id="lightning" />

    <script>
        $Lightning.use("c:myComponent", function () {
            $Lightning.createComponent("c:myComponent",
                { 
                    ...
                },
                "lightning"
            );
        });
    </script>
</apex:page>

The component loads perfectly in my namespaced scratch org but once I install the package to a (QA) org the component does not render and instead displays a GACK error Error ID: 2051565161-29181 (-293734425).

Checking my browser console reveals this exception:

{
    "stack": "Error: Blocked a frame with origin https://my-scratch-domain.ap5.visual.force.com from accessing a cross-origin frame.↵    at injectIntoContentWindow (<anonymous>:26:34)↵    at HTMLIFrameElement.contentWindowDesc.get [as contentWindow] (<anonymous>:60:7)↵    at l (https://my-scratch-domain.ap5.visual.force.com/jslibrary/1558397236222/sfdc/SfdcSessionBase208.js:30:193)",
    "code": 18,
    "name": "SecurityError",
    "message": "Blocked a frame with origin https://my-scratch-domain.ap5.visual.force.com from accessing a cross-origin frame."
}

When I changed the code in VF page to use namespace:AppName and namespace:componentName it magically fixed the error

Is this an expected behavior? Reading the documentation I think I could omit the use of namespaces inside a packaging or or a namespaced scratch org:

To reference this app on your page, use the following JavaScript code, where theNamespace is the namespace prefix for the app. That is, either your org’s namespace, or the namespace of the managed package that provides the app.

$Lightning.use("theNamespace:lcvfTest", function() {}); If the app is defined in your org (that is, not in a managed package), you can use the default “c” namespace instead, as shown in the next example. If your org doesn’t have a namespace defined, you must use the default namespace.

0

You must log in to answer this question.