Add Components to Managed Packages
Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.
A managed package ensures that your application and other resources are fully upgradeable.
To create and work with managed packages, use a Developer Edition organization and register a namespace prefix. A managed package includes your namespace prefix in the component names and prevents naming conflicts in an installer’s organization.
A custom Lightning web component can’t reference a Lightning web component installed from a managed package. See Component Namespaces.
AppExchange partners have two types of managed packages to choose from: second-generation managed packages (2GP) and first-generation managed packages (1GP). When working with managed packages, follow these guidelines.
- We recommend using 2GP for all new managed packages. To add components to your 2GP, include the components in your package directory and then create a package version.
- Add components to your 1GP by adding them in your 1GP packaging org.
When you add a component to a package, other components referenced by the component and any resources imported with @salesforce/*
are automatically included. For more information, see @salesforce Modules.
After a package is released, the component name is locked, but the package developer can still edit these values in a component’s configuration file.
apiVersion
description
isExposed
(can only change fromfalse
totrue
)masterLabel
targetConfigs
targets
Keep these considerations about the isExposed
field in mind when working with 1GP, 2GP, and unlocked packages.
- If
isExposed
isfalse
, the package developer can remove configuration targets and a public (@api) property from a component. - If
isExposed
istrue
and the component is in a published managed package, the package developer can’t remove configuration targets or a public (@api
) property from a component. This restriction is enforced even if the target or public property was added after the most recent publication of the package. - When you delete a Lightning web component with an
isExposed
value oftrue
, we recommend a two-stage process to ensure that the deleted component has no dependencies on the other items in the package. See Remove Components from Second-Generation Managed Packages.
By default, LWC doesn't automatically enforce managed package licensing. Users can see and use Lightning web components in a managed package even if they don’t have active licenses for that package. Users can also see and use Lightning web components in a managed package after a trial of that managed package expires. AppExchange partners are responsible for enforcing package licensing in their components.
We recommend that you use an Apex controller that calls either the UserInfo.isCurrentUserLicensed(namespace)
or UserInfo.isCurrentUserLicensedForPackage(packageID)
methods. If false
is returned, don't render the component. Instead, show a message informing the user they aren't licensed for the managed package.
See Also
- ISVforce Guide
- Second-Generation Managed Packaging Developer Guide: Components Available in Managed Packages