Skip to main content
edited tags
Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508
Became Hot Network Question
Tweeted twitter.com/StackSalesforce/status/1275805922711961600
edited title
Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

Install namespace-less Organize Managed Package Dependencies with Unlocked package in namespaced scratch orgPackages

added 101 characters in body
Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

I build Managed Packages (with namespaces) for my ISV customers. I use external libraries and Open-Source frameworks like fflib or apex-domainbuilder and find dependency management gets more cumbersome the more external libs I use.

I decided to use Unlocked Packages to bundle and manage such dependencies better. Here are the sfdx-project.json files for the app and for a sample dependency.

sfdx-project.json of the Managed Package (Customer DevHub)

{
    "namespace": "NAMESPACE",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageDirectories": [{
        "path": "force-app",
        "versionNumber": "1.1.0.NEXT",
        "package": "myManagedPackage",
        "dependencies": [
            {
            "package": "noNsUnlockedDependency@LATEST",
            }
        ]
    }],
    "packageAliases": {
        "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
        "noNsUnlockedDependency@LATEST": "04t4A000000onRXQAI",
    }
}

sfdx-project.json of the Required Library (Developer Devhub XYZ)

{
    "packageDirectories": [{
        "path": "force-app",
        "default": true,
        "package": "apex-domainbuilder",
        "versionName": "Summer '20",
        "versionNumber": "1.1.0.NEXT"
    }],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageAliases": {
    "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
    "[email protected]": "04t4A000000onRXQAI"
    }
}

As the sample dependency is created from another DevHub and/or doesnt have a namespace I can't install them.

ERROR running force:package:install: You cannot install an unlocked package without a namespace into an org with a namespace.

  1. Why is that a requirement?
  2. Is it because the libraries use a different DevHub (the one of our company) than the Managed package (the one of the customer)?
  3. I don't want (I read that this has some problems and limitationshere that this has some problems and limitations) or can't (because they are not my repos) add namespaces.
  4. What will I win and lose when adding namespace to the dependencies?

I build Managed Packages (with namespaces) for my ISV customers. I use external libraries and Open-Source frameworks like fflib or apex-domainbuilder and find dependency management gets more cumbersome the more external libs I use.

I decided to use Unlocked Packages to bundle and manage such dependencies better. Here are the sfdx-project.json files for the app and for a sample dependency.

sfdx-project.json of the Managed Package (Customer DevHub)

{
    "namespace": "NAMESPACE",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageDirectories": [{
        "path": "force-app",
        "versionNumber": "1.1.0.NEXT",
        "package": "myManagedPackage",
        "dependencies": [
            {
            "package": "noNsUnlockedDependency@LATEST",
            }
        ]
    }],
    "packageAliases": {
        "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
        "noNsUnlockedDependency@LATEST": "04t4A000000onRXQAI",
    }
}

sfdx-project.json of the Required Library (Developer Devhub XYZ)

{
    "packageDirectories": [{
        "path": "force-app",
        "default": true,
        "package": "apex-domainbuilder",
        "versionName": "Summer '20",
        "versionNumber": "1.1.0.NEXT"
    }],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageAliases": {
    "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
    "[email protected]": "04t4A000000onRXQAI"
    }
}

As the sample dependency is created from another DevHub and/or doesnt have a namespace I can't install them.

ERROR running force:package:install: You cannot install an unlocked package without a namespace into an org with a namespace.

  1. Why is that a requirement?
  2. Is it because the libraries use a different DevHub (the one of our company) than the Managed package (the one of the customer)?
  3. I don't want (I read that this has some problems and limitations) or can't (because they are not my repos) add namespaces.
  4. What will I win and lose when adding namespace to the dependencies?

I build Managed Packages (with namespaces) for my ISV customers. I use external libraries and Open-Source frameworks like fflib or apex-domainbuilder and find dependency management gets more cumbersome the more external libs I use.

I decided to use Unlocked Packages to bundle and manage such dependencies better. Here are the sfdx-project.json files for the app and for a sample dependency.

sfdx-project.json of the Managed Package (Customer DevHub)

{
    "namespace": "NAMESPACE",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageDirectories": [{
        "path": "force-app",
        "versionNumber": "1.1.0.NEXT",
        "package": "myManagedPackage",
        "dependencies": [
            {
            "package": "noNsUnlockedDependency@LATEST",
            }
        ]
    }],
    "packageAliases": {
        "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
        "noNsUnlockedDependency@LATEST": "04t4A000000onRXQAI",
    }
}

sfdx-project.json of the Required Library (Developer Devhub XYZ)

{
    "packageDirectories": [{
        "path": "force-app",
        "default": true,
        "package": "apex-domainbuilder",
        "versionName": "Summer '20",
        "versionNumber": "1.1.0.NEXT"
    }],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageAliases": {
    "noNsUnlockedDependency": "0Ho4A000000fxXpSAI",
    "[email protected]": "04t4A000000onRXQAI"
    }
}

As the sample dependency is created from another DevHub and/or doesnt have a namespace I can't install them.

ERROR running force:package:install: You cannot install an unlocked package without a namespace into an org with a namespace.

  1. Why is that a requirement?
  2. Is it because the libraries use a different DevHub (the one of our company) than the Managed package (the one of the customer)?
  3. I don't want (I read here that this has some problems and limitations) or can't (because they are not my repos) add namespaces.
  4. What will I win and lose when adding namespace to the dependencies?
deleted 1 character in body
Source Link
Phil Hawthorn
  • 16.8k
  • 4
  • 49
  • 76
Loading
added 6 characters in body
Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508
Loading
added 180 characters in body
Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508
Loading
Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508
Loading