1

I am a newbie and I am faced with the following task: to set a namespace prefix for my organization, as well as to create a managed package, develop an LWC component and add it to a managed package. I created a new Scratch Org and created my own component there. I also have separate organizations Developer Edition (with the namespace installed) and DevHub (where the managed package is created). Do I understand correctly that my component from Scratch One needs to be moved to DevHub in order to be able to add it to a managed package? Or can it be somehow linked to DevHub?

4

The paradigm differs depending on whether you are building a First-Generation Managed Package or a Second-Generation Managed Package. While 2GP is preferred for new projects, you should confirm which style of package you're being asked to created.

Since you already have the Dev Hub and packaging org or namespace org in place, you'd need to do next...

First-Generation Managed Package

For a 1GP, you would need to

  • Create a package in your packaging org.
  • Retrieve the metadata from your scratch org into version control.
  • Deploy the metadata from version control into your packaging org.
  • Add the metadata to the package in the Packaging UI in the packaging org.
  • Upload a beta or released package version from the Packaging UI.

Check out Package an AppExchange App on Trailhead.

Second-Generation Managed Package

For a 2GP, you would:

  • Retrieve the metadata from your scratch org into version control.
  • Create a package in the Dev Hub using the force:package:create SFDX command.
  • Create a package version using the force:package:version:create SFDX command, which uploads metadata directly from your source control.
  • Optionally, promote the package version to allow it to be installed in a production org.

Check out Package Development Model on Trailhead.

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.