HomeAbout

NX

What is it

nx is a monorepo framework for

Why use it

Caches for speed.

Parallel run for each workflow.

Visibility using graph.

apps vs libs

Apps = deployable artifacts

Libs = Actual code and business logic

Approach

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.

Naming of folders

The folders generated corresponding to apps and libs can be found in nx.json.

  • It can be customized to have other names, but is not recommended
"workspaceLayout": { "appsDir": "apps", "libsDir": "libs" }

Keywords

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 checking

e,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" ] }
AboutContact