Not being able to reference packaged custom LWCs from other LWCs outside the package

This restriction referenced from Distribute Components on AppExchange:

A custom Lightning web component can’t access a Lightning web
component or module in a custom namespace. It can access Lightning web
components and modules only in the c and lightning namespaces.

says you can’t have your custom LWC’s in a package and use them in LWCs outside the package. This is a substantial and surprising restriction: packages are an important distribution mechanism in Salesforce (particularly for ISVs), so components and packages not working together seems like a major miss.

  1. For people who are using LWCs and multiple packages together, how have you organised to work-around this problem?
  2. Is this a permanent situation, or something that will change in the future?
  3. Any estimates on how far in the future?
  4. Is there a big technical challenge to overcome, or is it more that this hasn’t made it up the priority list yet?

PS Voting here Use a Lightning Web Component from another Package/Namespace? might help.

PPS Just hit this again today. We have a component in a managed package that was developed using slots as an extension mechanism because the extension needs to be markup not data that generates markup. But that can’t be wrapped in another LWC from outside the package because of this restriction. (And I assume wrapping in Aura will not allow the slots to be used?) This is so broken if you are an ISV.

Answer

Cross namespace import and communication is currently restricted because of a security limitation in LWC. With our current Lightning Locker architecture there just isn’t a secure way to enable it. The good news is that UI Security team is actively working on a new architecture that will enable secure namespace import and communication. It isn’t a small undertaking and requires significant changes in order for cross namespace communication to meet our strict security standards. The team is about two releases away before we can begin a pilot for customers and ISVs, in the meantime the UI Security team will be active with external communication as we have updates. I’ll follow up here as they are available.

Attribution
Source : Link , Question Author : Keith C , Answer Author : Kiril Seksenov

Leave a Comment