Is there a way to make a package dependent on unpackaged stuff (not another package)?

  • without having to turn that stuff itself into unlocked package.
  • without including its metadata in package.

The idea was to leave legacy code unpackaged. Does this make sense?


Unfortunately, this is not possible. All dependencies must be resolvable to another package member. This is the same basic rules as Managed Packages for the AppExchange. The theory is that these packages must be installable in any org, and must therefore be complete enough to be deployed as such.

The main way around this is to start with a single, massive Unlocked Package that contains everything in your org. Then, make other packages dependent on the first, and use the DeprecateOnly upgrade option to migrate metadata from the mega-package to a new package as you modularize your org.

Moving Metadata Between Packages

sfdx force:package:version:create -p package1 -x -w 100
sfdx force:package:version:create -p package2 -x -w 100
sfdx force:package:install -p "package1@0.1.0-2" -w 100 --upgradetype DeprecateOnly
sfdx force:package:install -p "package2@0.1.0-1" -w 100

With the Release of Winter '21, you can now sign up for a Pilot that allows you to specify unpackaged metadata for your packages: https://docs.releasenotes.salesforce.com/en-us/winter21/release-notes/rn_sfdx_packaging_path_unpackaged_md.htm?edition=&impact=

"packageDirectories": [
    "path": "force-app",
    "package": "TV_unl", 
    "versionName": "ver 0.1",
    "versionNumber": ""0.1.0.NEXT",
    "default": true, 
    "unpackagedMetadata": {
        "path": "my-unpackaged-directory"
    "path": "my-unpackaged-directory",
    "default": false

This answer is for all the people ending up here from a google search.

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.