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.
- Why is that a requirement?
- Is it because the libraries use a different DevHub (the one of our company) than the Managed package (the one of the customer)?
- 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.
- What will I win and lose when adding namespace to the dependencies?