Package Development Model
Use package development model for developing against orgs with source tracking such as scratch orgs. This model tracks the changes you make on your local workstation and in your default development org. Use packaged sets of metadata to move changes between orgs. See the Package Development Model Trailhead module.
To start developing with this model:
- Open the VS Code editor and from the Command Palette, run SFDX: Create Project.
If you want to work on an existing project, choose File > Open and navigate to the project directory. Before you open an existing project in VS Code, make sure that your project has a
sfdx-project.jsonfile and that metadata is in source format.
- For information on the project structure, see Project Setup in the Salesforce DX Developer Guide.
- You can work with source-tracked orgs only if your metadata is in source format. See Source Format (./en/user-guide/source-format).
- In the code editor’s status bar, click Org Picker to open the Command Palette.
- Run SFDX: Authorize an Org. If you don’t have a Dev Hub, see Enable Dev Hub in Your Org in the Salesforce DX Setup Guide.
- Click Org Picker and run SFDX: Create a Default Scratch Org to create and set a scratch org as your default org for development.
- Select the scratch org shape, enter an alias, and enter the duration when the scratch org expires. The Org Picker now shows the alias provided for the scratch org. You can click the browser icon () in the status bar to open the default org you are working against. To change the default org you’re developing against, click the Org Picker and select a different org. Or, open the Command Palette and run SFDX: Authorize an Org or SFDX: Create a Default Scratch Org.
Push and Pull Source
When you use the package development model, it’s simple to keep your local project and default development org in sync. Because you deploy your changes to other orgs using packaged sets of metadata, there’s no need to manually track your changes. VS Code is context aware that you are working in a scratch org and provides only push and pull commands, not commands to retrieve and deploy source.
To push your source to the new scratch org or changes you made, run SFDX: Push Source to Default Scratch Org.
If you want the changes in the project to overwrite changes in the scratch org, run SFDX: Push Source to Default Scratch Org and Override Conflicts.
After you make changes in your browser, run SFDX: Pull Source from Default Scratch Org to update your project.
If you want the changes in the scratch org to overwrite changes in the project, run SFDX: Pull Source from Default Scratch Org and Override Conflicts.
Before you push local changes to the scratch org or pull remote changes to the local project, you can see the changes in the Output panel. To do so, run SFDX: View Changes in Default Scratch Org from the Command Palette.