0

I am quite confused with the 2nd generation package dev process.

Based on the documentation here, https://developer.salesforce.com/docs/atlas.en-us.pkg2_dev.meta/pkg2_dev/sfdx_dev_dev2gp_before.htm

  • I have signed up a PBO(Partner business org) and enable it as Dev Hub.
  • I have also signed up a DE org (Developer Edition Org) to create the namespace.

Then in PBO, I used the 'namespace registries' app to successfully associated namespace ceated in Dev org with my PBO.

Here is the confusing part: For development, the document suggest I should use scratch org created from PBO.

My questions:

  1. Could we use Developer Edition org for development or it is just used only for the namespace creation?
  2. If DE org it is just for namespace creation, why SF cannot simplify this as create one org purely for namespace sounds like overkill to me.
  3. In PBO, we can still create sandbox. Could we use those sandboxes for development or just the Scratch org only?

I am quite new to this process so apologize for those newbie questions, thank you very much.

2 Answers 2

3

Could we use Developer Edition org for development or it is just used only for the namespace creation?

You can use the Developer Edition org as well to build and deploy code. However, it is not recommended since 2GP packages are source driven.

Source Driven means while package creation the CLI command either looks at the source code in your local (if you are generating packages manually via CLI from your laptop) or your git branch (if you are using an automated script via a CI/CD tool).

If DE org it is just for namespace creation, why SF cannot simplify this as create one org purely for namespace sounds like overkill to me.

You are right this is an additional hop at this point. There is are some technical implications on the Salesforce end. You can open an idea on the Salesforce IdeaExchange

In PBO, we can still create sandbox. Could we use those sandboxes for development or just the Scratch org only?

Scratch orgs are different than sandboxes. Scratch orgs are ephemeral while sandboxes are not. Typically you should be using scratch orgs to build and test. Sandboxes for scale testing and UAT because they have storage capacity like production and also can be cloned. You would install 2GP packages in sandbox to test them.

1
  • fair enough, thank you
    – Wayne Ni
    Commented Mar 16 at 23:20
2

Do not use dev orgs or sandboxes, and only use the PBO as your Dev Hub. Use scratch orgs and a version control system such as git.

You store all metadata in the VCS. You create a scratch org per work item (and per dev) and deploy the metadata to it. You do that item's work there and pull it down so you can save the changes to your VCS.

This ensures that:

  1. Collaboration is via the VCS.
  2. The VCS is the "source of truth".
  3. Every piece of work is isolated from each other during development.
  4. You always start from a clean setup every time (you don't have the org contain anything that should not be there, because such stuff is not in your VCS).

If you use long lived orgs for your development you risk these accumulating metadata that is not part of you package (e.g. experimental stuff that eventually isn't to be part of the package) and for this to cause problems with later work, and inconsistencies between the developer experiences. It can even lead to what is developed being different to what is packaged.

The dev org is literally just for the namespace creation. Why you need an org for this? Because that is how it works.

PS: We use exactly the same processes for 1GP development with one extra step, which is to deploy the metadata to the packaging org. This is not needed for 2GP development since the packaging orgs are transients managed during package version creation.

3
  • thanks for clear explanation but I have to make the other one as best as it come first and also a goos answer.
    – Wayne Ni
    Commented Mar 16 at 23:22
  • You are at liberty to choose whichever answer you feel answers your question best. I personally disagree with Mo for saying you could use dev orgs for your development at all. While it is technically possible it would be entirely wrong to do so and the way he puts it does not explain why it is a bad idea, just that it is against recommendation.
    – Phil W
    Commented Mar 17 at 8:16
  • I second that. Technically you can do that, but it will take you nowhere
    – Wayne Ni
    Commented Mar 17 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .