Press enter to see results or esc to cancel.

What are Org-Dependent Unlocked Packages?

Org-dependent unlocked packages are certain type of unlocked packages that allow us to create packages that depend on the metadata in the destination org (where we are going to install the package).

Why do we need Org-Dependent Unlocked Packages?

If the production org is existed for very very long time and with so much of complexity, untangling the metadata from this type of organizations will be very difficult. In case if we are adopting the package based development model and not able to modularize everything that exist in the org then org-dependent unlocked packages are here to rescue.

The logic with this variation of unlocked packages (org-dependent) is the metadata validation occurs at the time of installation not at the time of package creation. So if we can take care of the dependencies in the destination org then we no need to worry about any errors.

Note: What ever the package development steps applies to unlocked packages the same applies to the org-dependent unlocked packages also.

How to create Org-Dependent Unlocked Packages?

Like we discussed above the org-dependent unlocked packages are a variation of unlocked packages so the package creation follows the same way but with –orgdependent attribute.

Command: sfdx force:package:create -t Unlocked -r force-app -n MyPackage –orgdependent

There are certain points to remember when we are planning to use org-dependent unlocked packages.We will see the differences when to use traditional unlocked packages v/s org-dependent unlocked packages.

Traditional unlocked packages:

  1. These unlocked packages we can create once and use anywhere. Because the metadata validation happens at the time of package creation and there are no other metadata dependencies present except for those defined in the definition file (optional).
  2. Dependency validation happens at the time of package creation and all the dependencies needs to be resolved to create the package
  3. This package creation can depend on other unlocked/managed packages.
  4. Supported metadata types this is same for both the types.
  5. Better to use scratch orgs to develop and test the unlocked packages.
  6. As the code coverage is must these packages needs to maintain 75% code coverage requirement.

Org-Dependent Unlocked Packages

  1. These org-dependent unlocked packages can’t be used everywhere, As the metadata validation will not happen at the time of package creation hence the dependencies will not be checked. So these packages are created for specific sandbox/production org where the dependent metadata already existed.
  2. Dependency validation happens at the time of package installation and all the dependencies needs to be resolved before installing the package.
  3. This package creation can’t depend on other unlocked/managed packages.
  4. Supported metadata types this is same for both the types.
  5. Better to use recently refreshed sandbox where Source Tracking is enable in sandboxes.
  6. Code coverage will not be checked but it the responsibility of the Developer to maintain the required code coverage inside the org-dependent unlocked package.