nx
is a monorepo framework for
Caches for speed.
Parallel run for each workflow.
Visibility using graph.
apps
vs libs
Apps = deployable artifacts
Libs = Actual code and business logic
libs
is not about holding the shared code.
In NX, the goal is to have almost no code in apps
and have almost all of the code located in libs
.
Even code that won't be shared between apps should be put into libs
.
The folders generated corresponding to apps
and libs
can be found in nx.json
.
"workspaceLayout": { "appsDir": "apps", "libsDir": "libs" }
scope
Scope defines a logical group or domain which contains multiple libs.
type
Type defines content of the library and its purpose and usage.
platform
Libraries can be tagged with platform if they are used for specific device usage.
tags
Define module boundary rules so violations are caught.
eslint
is used for static checkinge,g, type:util
tagged lib can only be used by other libs with the same tag.
Tags are defined in nx.json
:
"some-scope": { "tags": ["type:shared", "scope:some-scope"] }
In eslintrc.json
:
{ "sourceTag": "scope:some-scope", "onlyDependOnLibsWithTags": [ "scope:shared" ] }