Table of contents
The apps and libraries in the monorepo can make use of tags to mark rules for dependencies.
Back to Mono repo NX setup
You can add "tags": ["type:app", "type:util", "type:feature", "type:ui", "type:theme"]
to the project.json
file.
- Apps should only depend on feature and util
- feature should only depend on ui, util and data-access
- ui should only depend on util
- data-access should only depend on util
Make use of the sourceTag and onlyDependantOnLibsWithTags properties, inside of "@nrwl/nx/enforce-module-boundaries"
present in the .eslintrc.json
file to create rules and mark project dependencies.
Example:
{
"sourceTag": "type:app",
"onlyDependantOnLibsWithTags": ["type:feature", "type:util"]
},
{
"sourceTag": "type:feature",
"onlyDependantOnLibsWithTags": ["type:ui", "type:util", "data-access"]
},
{
"sourceTag": "type:ui",
"onlyDependantOnLibsWithTags": ["type:util"]
},
{
"sourceTag": "type:data-access",
"onlyDependantOnLibsWithTags": ["type:util"]
},
Back to Mono repo NX setup
This mono repo has two generators present, tag and ui, as examples.
The tag generator creates libraries and assigns tags on creation. You can chose your library name, platform, scope and tag.
Usage:
nx workspace-genearator tag my-new-library
or use the VisualStudio code addon.
The ui generator uses template files to bootstrap a component with all it's starter files.
Back to Mono repo NX setup
Running nx dep-graph
Back to Mono repo NX setup
Running nx affected:build
should come back with a message: NX No projects with "build" were run
Running nx affected:build
should come back with a message:
NX Running target build for 3 project(s) and 1 task(s) they depend on:
- healthcare
- vitamin
- web
All healthcare, vitamin and web have in the dependency tree the TextField component.
Running nx affected:build
should come back with a message:
NX Running target build for 1 project(s) and 1 task(s) they depend on:
- healthcare
Only the healthcare app depends on FeatureCart
Back to Mono repo NX setup
As you can see in the CODEOWNERS file, you can configure protected paths inside your mono repo, that can be picked up by GitHub and GitLab. This will enable an option in GitHub or GitLab when creating custom protection rules for branches, that will allow you to check that this pull request must be approved by one of the entities with access present in the CODEOWNERS file.
Split tickets into smaller ones or use tasks to evolve into keeping pull requests short lived to speed up access to features and bug fixes for other teams.
Develop new features under "sourceTag": "stability:experimental"
, so linter can complain if anyone want to use it in production.
- enhance the mono-repo with more generators and rules
- component file structure (pages, features, ui, util, data-access)
- theming: base and variation themes
- using media files: vectors, images etc
- using simple icons as vectors in fonts
- responsive or fluid typography
- SEO evaluation and guide
- Custom ESLint rules and fix
- Support multiple API version
- Pipeline distrubute workload (split into multiple jobs using
nx print-affected
)
├── apps
│ ├── clothes4u
│ ├── get-fit
│ ├── my-app
│ └── win-machine
└── libs
├── feature
│ ├── card
│ ├── cta
│ ├── footer
│ ├── hero
│ ├── login
│ └── side-menu
├── feature-get-fit
│ ├── checkout
│ │ ├── basket
│ │ ├── buy-more
│ │ ├── invoice
│ │ ├── product-list
│ │ └── product-review
│ └── color-picker
├── feature-my-app
│ ├── avatar-builder
│ ├── cash-manager
│ ├── profile-selector
│ ├── shared
│ │ ├── live-status
│ │ └── profile-display
│ └── time-manager
├── store
├── theme
├── theme-get-fit
├── theme-my-app
├── ui
│ ├── button
│ ├── divider
│ ├── flex
│ ├── grid
│ ├── smart-table
│ └── text-field
└── util
├── calculator
├── formatter
└── language