Skip to main content

#Package Dependency0 discussing

I've successfully released a Second Generation Unlocked Package that relies on two separate First Generation Managed Packages.

 

The Second Generation Unlocked Package and First Generation Managed Packages are in separate Developer Hubs. 

 

This dependancy has currently been defined using the 04t IDs for the 1GP Managed Package Versions. 

 

This means that when the 1GP Managed Packages are updated I'll also have to manually update the 2GP to rely on the new version. 

 

Is there are a better way to handle this? 

 

cc @Pronit Agrawal

 

#Unlocked Packages #Second Generation Packages #Package Dependency 

3 answers
  1. Jan 21, 2025, 2:16 PM

    There is no automated way to do this but also remember that dependencies are a "minimum version" NOT an exact version. This means you only need to update your dependencies if you are changing your package to directly reference new features/metadata in the 1GP packages that a new to the 1GP package. You can leave you dependencies for a long time but still install the latest 1GP package versions and Salesforce will happily allow installing your 2GP as well.

0/9000

Creating a scratch org for 2GP development with dependencies: too slow

 

We are just setting out on our journey with 2GP. Our first 2GP is a new "extension package" that integrates our core product (an existing 1GP) with a third-party product (another existing 1GP). As such, a scratch org for the 2GP development requires us to have both packages installed since the integration will add fields to objects from both packages and include Apex code using objects from both packages.

 

I have added appropriate details in the sfdx-project.json file listing the two dependencies, something like:

 

{

    "namespace": "mynamespace",

    "sfdcLoginUrl": "https://login.salesforce.com",

    "sourceApiVersion": "48.0",

    "packageDirectories": [

        {

            "path": "force-app",

            "default": true,

            "package": "My Integration Package",

            "versionNumber": "0.0.1.NEXT",

            "definitionFile": "config/myint-scratch-def.json",

            "dependencies": [

                {

                    "package": "CorePackage@2.1.2.1"

                },

                {

                    "package": "ThirdParty@5.10.4.1"

                }

            ]

        }

    ],

    "packageAliases": {

        "CorePackage@2.1.2.1": "04t0N000000AAAAAAA",

        "ThirdParty@5.10.4.1": "04t4P000002BBBBBBB"

    }

}

 

Of course, this doesn't actually handle installation of the packages when creating the scratch org, and I have written some scripting to pull required details from this JSON file (plus installation keys from "elsewhere") to handle the necessary force:package:install commands prior to pushing our new 2GP code to the scratch org. (See more on this in the final two paragraph.)

 

However, right now (with a basically empty 2GP development source tree) simply creating the scratch org and deploying the two dependencies is taking just short of an hour.

 

We normally work with a scratch org per developer per task, so we know the scratch org is clean and fit for purpose. We also have continuous integration which again creates a scratch org each time code is committed to git. This becomes untenable when it takes this long just to create the scratch org and get it populated.

 

In the short term we can drop CI for this package and have developers use long lived scratch orgs (30 days) for all the 2GP development, so the creation time only happens monthly, but this is not ideal and could expose us to issues with cruft the devs create on their orgs.

 

What I'm looking for is a way to speed up the creation of the scratch org, including the installed packages.

 

It appears there was some work done around allowing scratch orgs to be created using a TSO snapshot, presented at Dreamforce 18 (see https://twitter.com/FishOfPrey/status/1044644000316026880) which would be ideal here I believe. We could install the 1GPs into the TSO, create a snapshot and build the scratch org from that. However, the mechanism used (the "template" property in the scratch def JSON file) isn't documented and there's no other mention of this approach elsewhere in official documentation.

 

I understand from a comment on Stack Exchange (https://chat.stackexchange.com/rooms/107428/discussion-on-question-by-phil-w-how-to-speed-up-scratch-org-creation-when-it-in) that this feature hasn't been GAed, may not even be available for activation on request and only "marginally" improved performance (I am waiting for further feedback on the two latter points).

 

As an aside, it seems daft to me that you cannot include all the details necessary, in the sfdx-project.json file, to allow the SFDX CLI to create and initialize the scratch org completely. The only two "extras" I can see to achieve this would be to:

  • Allow specification of the installationKey for a dependency in the dependencies list.
  • Require any dependencies of dependencies that need an installationKey to have an explicit entry in the package dependencies list so the installationKey can be defined.

The force:org:create command could then take an additional parameter, such as "--install-dependencies", that causes the installation of the required dependencies in an appropriate order and leveraging the installation key values when required (and indeed there could be a new SFDX CLI command, e.g. force:org:install:dependencies or similar, to deal with this process directly too that the force:org:create command would simply delegate to when the parameter is set). This would avoid the need to write custom scripting just to install dependencies.

44 comments
0/9000

We want to add a manage package to our source control, as we are going to add some metadata that will be dependent on this managed package. The problem is this managed package is password protected and I cannot find a way to pass that installation key under the dependencies attributes.  I've found some similar cases but they were like 4 years old, so I'm wondering if anything has changed since then and is it possible to pass an installation key in dependency?  #Package Installation #Password #Package Dependency

8 answers
  1. Feb 11, 2022, 6:43 PM

    Why can't you script the installs and pass the installation key to the force:package:install command? Specifying installation key in the sfdx-project.json file is not supported.

0/9000

Is there a way to automatically reference the latest managed package version id in sfdx-project.json file? 

 

We're working in an org with Financial Services Cloud managed package installed, and our sandboxes have now been upgraded to Spring '20. As a result of the new release, the FSC manage package version also got updated along with it's package version id(04t...). Now I have to manually update my sfdx-project.json to reference the new package version id for our CI to work. Is there a way to automatically update the manage package version id in out config file? 

 

NOTE: in our deployment script, I'm checking if the referenced dependent package id is already deployed in a sandbox environment. If not, deploy dependent package, else skip dependency deployment.

11 comments
0/9000

Questions regarding org-dependent unlocked packages (Su '20 Release [Beta])

 

Preface

We are simultaneously trying to do a number of development "firsts" for us, including unlocked packages.  Our "happy soup" of metadata is as large as the lake outside our office building; but unfortunately we have too small of a team with major projects happening and in the works, so that none of us can currently spend the desired and necessary time to attempt to organize even the top level of a packaged metadata hierarchy.  So the new org-dependent unlocked packages functionality looks very promising to us.

 

Questions

  • After an org-dependent unlocked package is created, can it ever be transitioned to be dependent on a later-created unlocked package?
    • If so, what would be the steps?
    • If not, what are our options?

 

Thanks!

5 comments
  1. Jun 23, 2020, 4:41 PM
    @Eric (Moonpie)

    - you got it right, except the last paragraph.

    Let's presume you have metadata X, Y and Z in org-dependent unlocked package p1 version v1.

    Here's how you will transition to normal unlocked package.

    1) Create an unlocked package (not org-dependent package) p2 version v1. This package contains metadata X, Y and Z.

    2) Create version v2 of p1 after removing metadata X, Y and Z. You cannot have an empty package so add a dummy metadata M to v2 of p1.

    3) In the installed org, upgrade from p1-v1 to p1-v2. This "releases" X, Y and Z from package p1.

    4) In the installed org, install p2-v1. This makes X, Y and Z belong to package p2.

    5) Uninstall p1.

0/9000

Hi All,

 

I have a question regarding the package version creation. I am trying to distribute our Happy soup ORG into different unlocked packages. But facing some issues.

 

1. we have a Docusign managed package installed in the happy soup ORG

2. One of the Object in that Docusign managed package has a reference to a custom object. 

3.  First I created an unmanaged package with that Custom object to get all the related dependencies. 

4. Once I converted from the mdapi to src format, I could see the managed package object with a single reference field in src format like dsfs__DocuSign_Status__c.object-meta.xml

5. When I tried to push it to scratch ORG, then I got issues. saying 

'Must specify a non-empty label for the CustomObject'

6. Then I copied all the metadata of that dsfs__DocuSign_Status__c object in src format and pushed the whole object metadata to scratch ORG. Then it worked fine without no issues. 

7. Once everything done with no compilation issues, I tried to create a package version. Then I am getting the issues with this object saying

 

You're trying to include CustomObject dsfs__DocuSign_Status__c in Package ver 0.1. This component already exists in Package null, which Package ver 0.1 depends on. You can't include the same component in both packages.

 

What should I do now? I am completely stuck here. Please help me.

 

Thanks in advance

6 comments
  1. Apr 28, 2020, 5:46 PM
    Thank you @John Daniel/ @Marc Behr

    , that worked like a charm.

    I should pass -f config/project-scratch-def.json also while creating package since I have enabled some features/settings for Scratch ORG creation.

    Thanks a lot.

0/9000

Hi,

 

I'm currently struggling with a project involving dependent packages.

 

I currently have a child package which adds an email alert using an object created by the parent package. The parent package has no workflows at all, there's no directory named workflows/ either and installing the package and checking the components shows no workflows visible.

However, when I try to build the package, I always get a very strange error:

 

> $ sfdx force:package:version:create --package ChildPackage --path force-app --installationkey XXXXX --wait 10 --definitionfile config/project-scratch-def.json

> (truncated)

> ERROR running force:package:version:create:  You're trying to include Workflow namespace__Application__c in Package ver 0.2. This component already exists in Package ver 0.1, which Package ver 0.2 depends on. You can't include the same component in both packages.

 

I assume that Package ver 0.2 is the child object and Package ver 0.1 is the parent object which matches their actual version.

 

Details about the environment:

1. Both packages are attached to the same dev hub

2. Both packages created with this command: `sfdx force:package:version:create --package PackageName --path force-app --installationkey XXXXX --wait 10 --definitionfile config/project-scratch-def.json`

3. I'm trying to install them to a temporary scratch org - the parent package installs fine, the child package fails

Here's the `sfdx-project.json`

```

{

    "packageDirectories": [

        {

            "path": "force-app",

            "default": true,

            "package": "ChildPackage",

            "versionName": "ver 0.2",

            "versionNumber": "0.2.0.NEXT",

            "dependencies": [

                {

                    "package": "ParentPackage",

                    "versionNumber": "0.1.0.LATEST"

                }

            ]

        }

    ],

    "namespace": "namespace",

    "sfdcLoginUrl": "https://login.salesforce.com",

    "sourceApiVersion": "47.0",

    "packageAliases": {

        "ChildPackage": "0HoXXX",

        "ParentPackage": "0HoXXX",

        "ParentPackage@0.1.0-9": "04tXXX",

        ... multiple versions of ChildPackage ...

    }

}

```

Here is the project-scratch-def.json:

```

{

  "adminEmail": "XXX",

  "edition": "Developer",

  "features": [

    "Workflow",

    "Communities",

    "Sites"

  ],

  "settings": {

    "lightningExperienceSettings": {

      "enableS1DesktopEnabled": true

    },

    "communitiesSettings": {

      "enableNetworksEnabled": true

    }

  }

}

```

3 comments
0/9000

@Unlocked Packages, we are using the package strategies for the upcoming applications in our ORG. But when creating the unlocked packages, I am seeing some strange issues. Here are the two issues I see when creating package versions

 

1. Compilation issue

 

When executing the force:source:push everything looks good with no compilation errors. But when creating a package version, I am getting this issue. But, after 2-3 retrying attempts to create the package version, It would be successful. This is even happening in case of package upgrade with the same error. But, the package upgrade works fine after 2-3 retrying upgrade attempts. I even googled with this error but no luck. What exactly is this error mean? I am getting too frequently these days.

 

ERROR running force:package:version:create:  : Compilation Failure

        /c/ak_page/ak_page.js:0,0 : LWC1002: Error in module resolution: Maximum call stack size exceeded,ak_page: Compilation Failure

        /c/ak_page/ak_page.js:0,0 : LWC1002: Error in module resolution: Maximum call stack size exceeded

 

2. Error with non-related components while creating the package versions

 

While creating package version today, I got this issue. I am seeing errors with unrelated components. We even don't have any components with these names in our ORG/package. Why am I seeing these issues. But re-executing the creation worked fine. We have a package dependency on 04t4N000000omLKQAY package, but it's showing me 04t4N000000omLK in the logs with the following exceptions. These are not part of our ORG/Package.  

 

Request in progress. Sleeping 30 seconds. Will wait a total of 6000 more seconds before timing out. Current Status='Queued'

Request in progress. Sleeping 30 seconds. Will wait a total of 5970 more seconds before timing out. Current Status='Verifying dependencies'

ERROR running force:package:version:create:  An error occurred while trying to install a package dependency, ID 04t4N000000omLK: IMS_ViewBOLPdf: Invalid definition for null:IMS_ViewBOLPdfController: ApexService.getType() return null with currentNamespace: c, namespace: null, name: IMS_ViewBOLPdfController

 

Appreciate your response.

2 comments
  1. Oct 31, 2019, 8:16 PM
    @Marc Behr

    The package creation is not taking 2hrs. What I said is that it is taking 2-3 attempts to create the package. The package creation just takes 5-10 min if its success. (we have a couple of dependent packages for code reuse)

    The package we are trying to build is very minimal with

    7 LWC components

    50 classes contain interfaces, selectors..etc with SOC patterns depending on the fflib implementation (The dependencies I mentioned is the fflib package we built internally as an unlocked package)

    5 mdt components

    7 aura components

    10 fields across the different standard object

    It takes only 5-7 min max if its success in creating the package version. And also takes only a few mins while installing the package too. Also, all the dependent packages I mentioned are all internal packages created with our PROD devhub.

    something going wrong with the cross-references like I mentioned (IMS_ViewBOLPdfController is not part of any of our dependencies).

0/9000

Getting the below mentioned error,

"An error occurred while trying to install a package dependency, ID 04t1r000001G2dR: package.xml: Cannot use unfiled-public or user folders in a package"

 

The scenario is, I have a dependent package and while versioning it I am getting the error. The base package does not have anything related to unfiled-public folder although it is showing this error

0/9000

Hi All,

"You're trying to include Workflow abc__c in Package Code 0.1. This

component already exists in Package Obj 0.1, which Package Code 0.1 depends on. You can't include the same component in both packages"

 

Getting this error while versioning the package "Code 0.1". there is no workflow present in "obj 0.1" still I am getting this error.

is this a kind of bug present in SFDX ?

9 comments
0/9000