Skip to content

nhall97/sfdx-monorepo-npm-workspace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sfdx-monorepo-workspace

sfdx monorepo using NPM Workspaces to work with multiple sfdx projects eg. packages

The project is structured in the following

packages/
    /sfdx-core-package
        /package.json
    /sfdx-bonus-package
        /package.json
 package.json'

This is to provide a monorepo structure to our sfdx packages. The idea being that you can clone one repo, and work across many packages - to help make dependency management easier as well as refactoring.

The goal is to be able to provide a template sfdx-monorepo-workspace - to allow people to follow the same pattern with ease.

Instructions

//Check prereqs below before starting (npm > 7.0) 'git clone ' 'npm install'

test out below workspace commands that you're familiar with with sfdx: 'npm lint' : run linting across core package, and bonus package

ToDo

  1. Create workspace -Completed-
  2. Create a first package -Completed-
  3. Create a second package -Completed-
  4. Link packages to Workspace -Completed-
  5. Run npm install to generate package-lock -Completed-
  6. Validate sfdx commands in workspace

Outcomes

Are there any advantages to developing packages in a workspace?

BLOCKED: Cloudbuild and npm workspaces does not seem to be working correctly.

SFDX Command Validations

SFDX Command Workspace Command Working?
"lint": "npm run lint:lwc && npm run lint:aura", npm run lint --ws N
"lint:aura": "eslint /aura/",
"lint:lwc": "eslint /lwc/",
"test": "npm run test:unit",
"test:unit": "sfdx-lwc-jest",
"test:unit:watch": "sfdx-lwc-jest --watch",
"test:unit:debug": "sfdx-lwc-jest --debug",
"test:unit:coverage": "sfdx-lwc-jest --coverage",
"prettier": "prettier --write "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}"", npm run prettier --ws Y
"prettier:verify": "prettier --list-different "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}"", npm run prettier:verify --ws Y
"precommit": "lint-staged", npm run precommit --ws Y
"prepare": "cd ../../ && husky install front/.husky" npm run prepare --ws N

PreReqs

  • npm 7.0 >
  • husky > v7.0.1 due to this typicode/husky#1003 (comment)

    Lessons Learned

  • Husky should be installed in monorepo root - seems to fix issues with installs only in packages
  • About

    sfdx monorepo using NPM Workspaces to work with multiple sfdx projects eg. packages

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published