11

We have a lightning component thats part of our appexchange package. We have development environments with no namespace, a beta/staging package namespace, and our production package namespace. Is it possible to make the following namespace dynamic?

<ltng:require scripts="{!$Resource.yournamespace__resourceName}" styles="{!$Resource.yournamespace__resourceName}" />

Thanks!

  • 1
    In terms of workarounds, probably worth noting that this is one of those things DX solves since it lets you have scratch orgs with the same namespace - so any solution you come up with should probably assume you won't need it once you implement a DX workflow – BritishBoyinDC Oct 1 '18 at 13:28
0

It's not possible to make it dynamic, but you can try doing it like this:

<ltng:require scripts="{!$Resource.yournamespace1__resourceName}" styles="{!$Resource.yournamespace1__resourceName}" />
<ltng:require scripts="{!$Resource.yournamespace2__resourceName}" styles="{!$Resource.yournamespace2__resourceName}" />
<ltng:require scripts="{!$Resource.yournamespace3__resourceName}" styles="{!$Resource.yournamespace3__resourceName}" />

Since only one reference is valid in any given org, the resource would only be loaded via the valid reference.

| improve this answer | |
0

I faced the same issue.

And there is no possible way to make it dynamic. I have added the namespace manually in it and then commit it to production.

You can check out the below link. https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespace_using_reference.htm

| improve this answer | |
0

try this

<aura:attribute name="ns" type="String" description="pkg namespace" />
<ltng:require scripts="{! '/resource/<yourfoldername>/' + v.ns + '__' + <your resource name>}" />

Be sure to include any additional folders in the path with the folder name

| improve this answer | |

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.