
charlesembling
Nx: The Ultimate Node.js Mono Repo Tool
Why Don't We See More Mono Repos Being Used? Growing Trend?

Microservices & Mono Repos
What is a mono repo, who uses it, and why?

Why Use a Mono Repo?

Who Uses Mono Repos / And Nx?

What is Nx?

Check out the Intro: https://nx.dev/latest/angular/getting-started/intro
Who Created Nx?

Nx Key Features

•Setup/Review Workspace

•Creating Projects (generators)
Run the following commands to generate applications:
nx generate @nrwl/react:app web-appname-ui-react
nx generate @nrwl/angular:app web-appname-ui-angular
nx generate @nrwl/nest:app web-identity-api
nx generate @nrwl/nest:app web-appname-api
nx generate @nrwl/node:app console-documentDb
nx generate @nrwl/node:app console-dotnetcoreConsole
nx generate @nrwl/node:app console-cronJob
nx generate @nrwl/node:app cloud-azure-functions
When using Nx, you can create multiple applications and libraries in the same workspace.
Generate a library
Run the following commands to generate libraries.
nx g @nrwl/workspace:lib shared/db-orm
nx g @nrwl/workspace:lib shared/data-access
nx g @nrwl/workspace:lib shared/data-table
nx g @nrwl/workspace:lib shared/ui-header
nx g @nrwl/workspace:lib shared/ui-footer
nx g @nrwl/workspace:lib shared/util
nx g @nrwl/workspace:lib shared/util-dates
nx g @nrwl/workspace:lib shared/util-auth
nx g @nrwl/workspace:lib web-identity/api-types
nx g @nrwl/workspace:lib web-appname/api-types
nx g @nrwl/workspace:lib web-appname/ui
nx g @nrwl/workspace:lib shared/util-auth
nx g @nrwl/workspace:lib cloud/azure-sql-db
nx g @nrwl/workspace:lib cloud/azure-cosmos-db
nx g @nrwl/workspace:lib cloud/azure-storage
nx g @nrwl/workspace:lib cloud/azure-storage-datalake
nx g @nrwl/workspace:lib cloud/azure-service-bus
nx g @nrwl/workspace:lib cloud/azure-identity-aad
nx g @nrwl/workspace:lib cloud/azure-identity-b2c
Libraries are shareable across libraries and applications. They can be imported from @spacex/shared/util-auth.
Naming Conventions Are CRITICAL
Great article below:
An application:
can be built into a deployable artifact
contains a configuration for its build process
contains a configuration for runnings its tests
can consume code from libraries
A library:
contains code that can be consumed by applications or other libraries
contains a configuration for runnings its tests
can consume code from other libraries
A mono repo can contain multiple applications and multiple libraries.
•Creating Components (generators)
Run "nx g @nrwl/react:component my-component --project=web-appname-ui-react --directory components" to generate a new react component.
Run "nx g @nrwl/angular:component my-component --project=web-appname-ui-angular"
to generate a new angular component.
•Dependency Graph
Run "nx dep-graph"

•Running apps
Run "nx serve web-appname-api"
Run "nx serve web-appname-ui-react"
•Visualizing affected code
Run "nx affected:dep-graph" to see what was affected (this branch compared to main)

•Testing affected code
nx affected --target=test --all
Should You Consider Using Nx & Mono Repo in Your Next Project?

References
Nx
What is a Monorepo? - Perforce https://www.perforce.com/blog/vcs/what-monorepo
How to organize and name applications and libraries in an Nxmonorepo for immediate team-wide benefits
– Jurgen Van de Moere