You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/shared/concepts/buildable-and-publishable-libraries.md
+9-4
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Publishable and Buildable Nx Libraries
3
+
description: Learn about buildable and publishable libraries in Nx, when to use them, and how they adjust your project configuration for distribution.
4
+
---
5
+
1
6
# Publishable and Buildable Nx Libraries
2
7
3
8
The `--buildable` and `--publishable` options are available on the Nx library generators for the following plugins:
@@ -13,23 +18,23 @@ This document will look to explain the motivations for why you would use either
13
18
14
19
You might use the `--publishable` option when generating a new Nx library if your intention is to distribute it outside the monorepo.
15
20
16
-
One typical scenario for this may be that you use Nx to develop your organizations UI design system component library (maybe using its Storybook integration), which should be available also to your organizations’ apps that are not hosted within the same monorepo.
21
+
One typical scenario for this may be that you use Nx to develop your organizations UI design system component library (maybe using its Storybook integration), which should be available also to your organizations' apps that are not hosted within the same monorepo.
17
22
18
-
A normal Nx library - let’s call it "workspace library" - is not made for building or publishing. Rather it only includes common lint and test targets in its `project.json` file. These libraries are directly referenced from one of the monorepo’s applications and built together with them.
23
+
A normal Nx library - let's call it "workspace library" - is not made for building or publishing. Rather it only includes common lint and test targets in its `project.json` file. These libraries are directly referenced from one of the monorepo's applications and built together with them.
19
24
20
25
Keep in mind that the `--publishable` flag does not enable automatic publishing. Rather it adds to your Nx workspace library a builder target that **compiles** and **bundles** your app. The resulting artifact will be ready to be published to some registry (e.g. [npm](https://npmjs.com/)). By having that builder, you can invoke the build via a command like: `nx build mylib` (where "mylib" is the name of the lib) which will then produce an optimized bundle in the `dist/mylib` folder.
21
26
22
27
One particularity when generating a library with `--publishable` is that it requires you to also provide an `--importPath`. Your import path is the actual scope of your distributable package (e.g.: `@myorg/mylib`) - which needs to be a [valid npm package name](https://docs.npmjs.com/files/package.json#name).
23
28
24
-
To publish the library (for example to npm) you can run the CLI command: `npm publish` from the artifact located in the `dist` directory. Setting up some automated script in Nx’s `tools` folder may also come in handy.
29
+
To publish the library (for example to npm) you can run the CLI command: `npm publish` from the artifact located in the `dist` directory. Setting up some automated script in Nx's `tools` folder may also come in handy.
25
30
26
31
For more details on the mechanics, remember that Nx is an open source project, so you can see the actual impact of the generator by looking at the source code (the best starting point is probably `packages/<framework>/src/generators/library/library.ts`).
27
32
28
33
## Buildable libraries
29
34
30
35
Buildable libraries are similar to "publishable libraries" described above. Their scope however is not to distribute or publish them to some external registry. Thus they might not be optimized for bundling and distribution.
31
36
32
-
Buildable libraries are mostly used for producing some pre-compiled output that can be directly referenced from an Nx workspace application without the need to again compile it. A typical scenario is to leverage Nx’s incremental building capabilities.
37
+
Buildable libraries are mostly used for producing some pre-compiled output that can be directly referenced from an Nx workspace application without the need to again compile it. A typical scenario is to leverage Nx's incremental building capabilities.
33
38
34
39
{% callout type="warning" title="More details" %}
35
40
In order for a buildable library to be pre-compiled, it can only depend on other buildable libraries. This allows you to take full advantage of incremental builds.
Copy file name to clipboardexpand all lines: docs/shared/concepts/common-tasks.md
+2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
1
---
2
+
title: Common Tasks
3
+
description: Learn about standard task naming conventions in Nx projects, including build, serve, test, and lint tasks, for consistent project configuration.
Copy file name to clipboardexpand all lines: docs/shared/concepts/daemon.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Nx Daemon
3
+
description: Learn about the Nx Daemon, a background process that speeds up project graph computation in large workspaces by maintaining state between commands.
4
+
---
5
+
1
6
# Nx Daemon
2
7
3
8
In version 13 we introduced the opt-in Nx Daemon which Nx can leverage to dramatically speed up project graph computation, particularly for large workspaces.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/code-ownership.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Code Ownership
3
+
description: Learn about code ownership challenges in monorepos and how Nx helps manage shared code with tools like CODEOWNERS and module boundary rules.
4
+
---
5
+
1
6
# Code Ownership
2
7
3
8
One of the most obvious benefits of having a monorepo is that you can easily share code across projects. This enables you to apply the Don't Repeat Yourself principle across the whole codebase. Code sharing could mean using a function or a component in multiple projects. Or code sharing could mean using a typescript interface to define the network API interface for both the front end and back end applications.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/dependency-management.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Dependency Management Strategies
3
+
description: Compare independently maintained dependencies versus single version policy approaches for monorepos, with guidance on choosing the right strategy for your team.
4
+
---
5
+
1
6
# Dependency Management Strategies
2
7
3
8
When working with a monorepo, one of the key architectural decisions is how to manage dependencies across your projects. This document outlines two main strategies and helps you choose the right approach for your team.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/folder-structure.md
+6-1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Folder Structure
3
+
description: Learn about organizing your Nx monorepo with effective folder structures, and how to easily move or remove projects as your organization evolves.
4
+
---
5
+
1
6
# Folder Structure
2
7
3
8
Nx can work with any folder structure you choose, but it is good to have a plan in place for the folder structure of your monorepo.
@@ -51,7 +56,7 @@ libs/
51
56
52
57
One of the main advantages of using a monorepo is that there is more visibility into code that can be reused across many different applications. Shared projects are a great way to save developers time and effort by reusing a solution to a common problem.
53
58
54
-
Let’s consider our reference monorepo. The `shared-data-access` project contains the code needed to communicate with the back-end (for example, the URL prefix). We know that this would be the same for all libs; therefore, we should place this in the shared lib and properly document it so that all projects can use it instead of writing their own versions.
59
+
Let's consider our reference monorepo. The `shared-data-access` project contains the code needed to communicate with the back-end (for example, the URL prefix). We know that this would be the same for all libs; therefore, we should place this in the shared lib and properly document it so that all projects can use it instead of writing their own versions.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/monorepo-polyrepo.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Monorepo or Polyrepo
3
+
description: Evaluate the organizational considerations for choosing between monorepo and polyrepo approaches, including team agreements on code management and workflows.
4
+
---
5
+
1
6
# Monorepo or Polyrepo
2
7
3
8
Monorepos have a lot of benefits, but there are also some costs involved. We feel strongly that the [technical challenges](/concepts/decisions/why-monorepos) involved in maintaining large monorepos are fully addressed through the efficient use of Nx and Nx Cloud. Rather, the limiting factors in how large your monorepo grows are interpersonal.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/monorepos.md
+7-2
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Monorepos
3
+
description: Understand the benefits of monorepos including shared code, atomic changes, developer mobility, and consistent dependencies across your organization.
4
+
---
5
+
1
6
# Monorepos
2
7
3
8
A monorepo is a single git repository that holds the source code for multiple applications and libraries, along with the tooling for them.
@@ -8,7 +13,7 @@ A monorepo is a single git repository that holds the source code for multiple ap
8
13
9
14
-**Atomic changes** - Change a server API and modify the downstream applications that consume that API in the same commit. You can change a button component in a shared library and the applications that use that component in the same commit. A monorepo saves the pain of trying to coordinate commits across multiple repositories.
10
15
11
-
-**Developer mobility** - Get a consistent way of building and testing applications written using different tools and technologies. Developers can confidently contribute to other teams’ applications and verify that their changes are safe.
16
+
-**Developer mobility** - Get a consistent way of building and testing applications written using different tools and technologies. Developers can confidently contribute to other teams' applications and verify that their changes are safe.
12
17
13
18
-**Single set of dependencies** - [Use a single version of all third-party dependencies](/concepts/decisions/dependency-management), reducing inconsistencies between applications. Less actively developed applications are still kept up-to-date with the latest version of a framework, library, or build tool.
14
19
@@ -34,7 +39,7 @@ Nx provides tools to give you the benefits of a monorepo without the drawbacks o
34
39
35
40
-**Consistent Code Generation** - Generators allow you to customize and standardize organizational conventions and structure, removing the need to perform the same manual setup tasks repetitively.
36
41
37
-
-**Affected Commands** - [Nx’s affected commands](/nx-api/nx/documents/affected) analyze your source code, the context of the changes, and only runs tasks on the affected projects impacted by the source code changes.
42
+
-**Affected Commands** - [Nx's affected commands](/nx-api/nx/documents/affected) analyze your source code, the context of the changes, and only runs tasks on the affected projects impacted by the source code changes.
38
43
39
44
-**Remote Caching** - Nx provides local caching and support for remote caching of command executions. With remote caching, when someone on your team runs a command, everyone else gets access to those artifacts to speed up their command executions, bringing them down from minutes to seconds. Nx helps you scale your development to massive applications and libraries even more with distributed task execution and incremental builds.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/project-dependency-rules.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Project Dependency Rules
3
+
description: Learn how to organize your Nx workspace with library types like feature, UI, data-access, and utility libraries, and enforce dependency rules between them.
4
+
---
5
+
1
6
# Project Dependency Rules
2
7
3
8
There are many types of libraries in a workspace. You can identify the type of a library through a naming convention and/or by using the project tagging system. With explicitly defined types, you can also use Nx to enforce project dependency rules based on the types of each project. This article explains one possible way to organize your repository projects by type. Every repository is different and yours may need a different set of types.
Copy file name to clipboardexpand all lines: docs/shared/concepts/decisions/project-size.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Project Size
3
+
description: Understand the trade-offs of project granularity in Nx, including benefits like faster commands, clearer boundaries, and improved developer experience.
4
+
---
5
+
1
6
# Project Size
2
7
3
8
Like a lot of decisions in programming, deciding to make a new Nx project or not is all about trade-offs. Each organization will decide on their own conventions, but here are some trade-offs to bear in mind as you have the conversation.
Copy file name to clipboardexpand all lines: docs/shared/concepts/executors-and-configurations.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Executors and Configurations
3
+
description: Learn about Nx executors, pre-packaged node scripts that run tasks consistently across projects, and how to configure them in project.json files.
4
+
---
5
+
1
6
# Executors and Configurations
2
7
3
8
Executors are pre-packaged node scripts that can be used to run tasks in a consistent way.
Copy file name to clipboardexpand all lines: docs/shared/concepts/how-caching-works.md
+8-4
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: How Caching Works
3
+
description: Learn how Nx's computation hashing enables powerful caching, including what factors determine cache validity and how local and remote caches work together.
4
+
---
5
+
1
6
# How Caching Works
2
7
3
8
Before running any cacheable task, Nx computes its computation hash. As long as the computation hash is the same, the output of
@@ -18,11 +23,11 @@ By default, the computation hash for something like `nx test remixapp` includes:
18
23
19
24
After Nx computes the hash for a task, it then checks if it ran this exact computation before. First, it checks locally, and then if it is missing, and if a remote cache is configured, it checks remotely. If a matching computation is found, Nx retrieves and replays it. This includes restoring files.
20
25
21
-
Nx places the right files in the right folders and prints the terminal output. From the user’s point of view, the command ran the same, just a lot faster.
26
+
Nx places the right files in the right folders and prints the terminal output. From the user's point of view, the command ran the same, just a lot faster.
22
27
23
28

24
29
25
-
If Nx doesn’t find a corresponding computation hash, Nx runs the task, and after it completes, it takes the outputs and the terminal logs and stores them locally (and, if configured, remotely as well). All of this happens transparently, so you don’t have to worry about it.
30
+
If Nx doesn't find a corresponding computation hash, Nx runs the task, and after it completes, it takes the outputs and the terminal logs and stores them locally (and, if configured, remotely as well). All of this happens transparently, so you don't have to worry about it.
26
31
27
32
## Optimizations
28
33
@@ -96,8 +101,7 @@ Nx cache works on the process level. Regardless of the tools used to build/test/
96
101
97
102
{% /tab %}
98
103
99
-
If the `outputs` property for a given target isn't defined in the project'
100
-
s `package.json` file, Nx will look at the global, workspace-wide definition in the `targetDefaults` section of `nx.json`:
104
+
If the `outputs` property for a given target isn't defined in the project's `package.json` file, Nx will look at the global, workspace-wide definition in the `targetDefaults` section of `nx.json`:
Copy file name to clipboardexpand all lines: docs/shared/concepts/inferred-tasks.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Inferred Tasks (Project Crystal)
3
+
description: Learn how Nx plugins automatically infer tasks from tool configurations, enabling caching, task dependencies, and optimized execution without manual setup.
4
+
---
5
+
1
6
# Inferred Tasks (Project Crystal)
2
7
3
8
In Nx version 18, Nx plugins can automatically infer tasks for your projects based on the configuration of different tools. Many tools have configuration files which determine what a tool does. Nx is able to cache the results of running the tool. Nx plugins use the same configuration files to infer how Nx should [run the task](/features/run-tasks). This includes [fine-tuned cache settings](/features/cache-task-results) and automatic [task dependencies](/concepts/task-pipeline-configuration).
Copy file name to clipboardexpand all lines: docs/shared/concepts/mental-model.md
+15-10
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Mental Model
3
+
description: Understand how Nx works with project graphs, task graphs, affected commands, and caching to efficiently manage your monorepo development workflow.
4
+
---
5
+
1
6
# Mental Model
2
7
3
8
Nx is a VSCode of build tools, with a powerful core, driven by metadata, and extensible through [plugins](/concepts/nx-plugins). Nx works with a
@@ -6,13 +11,13 @@ with project graphs, task graphs, affected commands, computation hashing and cac
6
11
7
12
## The project graph
8
13
9
-
A project graph is used to reflect the source code in your repository and all the external dependencies that aren’t
14
+
A project graph is used to reflect the source code in your repository and all the external dependencies that aren't
10
15
authored in your repository, such as Webpack, React, Angular, and so forth.
Nx analyzes your file system to detect projects. Projects are identified by the presence of a `package.json` file or `project.json` file. Projects identification can also be customized through plugins. You can manually define dependencies between
15
-
the project nodes, but you don’t have to do it very often. Nx analyzes files’ source code, your installed dependencies, TypeScript
20
+
the project nodes, but you don't have to do it very often. Nx analyzes files' source code, your installed dependencies, TypeScript
16
21
files, and others figuring out these dependencies for you. Nx also stores the cached project graph, so it only
17
22
reanalyzes the files you have changed.
18
23
@@ -43,8 +48,8 @@ For instance `nx test lib` creates a task graph with a single node:
43
48
44
49
A task is an invocation of a target. If you invoke the same target twice, you create two tasks.
45
50
46
-
Nx uses the [project graph](#the-project-graph), but the task graph and project graph aren’t isomorphic, meaning they
47
-
aren’t directly connected. In the case above, `app1` and `app2` depend on `lib`, but
51
+
Nx uses the [project graph](#the-project-graph), but the task graph and project graph aren't isomorphic, meaning they
52
+
aren't directly connected. In the case above, `app1` and `app2` depend on `lib`, but
48
53
running `nx run-many -t test -p app1 app2 lib`, the created task graph will look like this:
49
54
{% side-by-side %}
50
55
@@ -62,11 +67,11 @@ running `nx run-many -t test -p app1 app2 lib`, the created task graph will look
62
67
{% /graph %}
63
68
{% /side-by-side %}
64
69
65
-
Even though the apps depend on `lib`, testing `app1` doesn’t depend on the testing `lib`. This means that the two tasks
70
+
Even though the apps depend on `lib`, testing `app1` doesn't depend on the testing `lib`. This means that the two tasks
66
71
can
67
72
run in parallel.
68
73
69
-
Let’s look at the test target relying on its dependencies.
74
+
Let's look at the test target relying on its dependencies.
70
75
71
76
```json
72
77
{
@@ -161,12 +166,12 @@ After Nx computes the hash for a task, it then checks if it ran this exact compu
161
166
and then if it is missing, and if a remote cache is configured, it checks remotely.
162
167
163
168
If Nx finds the computation, Nx retrieves it and replay it. Nx places the right files in the right folders and prints
164
-
the terminal output. So from the user’s point of view, the command ran the same, just a lot faster.
169
+
the terminal output. So from the user's point of view, the command ran the same, just a lot faster.
165
170
166
171

167
172
168
-
If Nx doesn’t find this computation, Nx runs the task, and after it completes, it takes the outputs and the terminal
169
-
output and stores it locally (and if configured remotely). All of this happens transparently, so you don’t have to worry
173
+
If Nx doesn't find this computation, Nx runs the task, and after it completes, it takes the outputs and the terminal
174
+
output and stores it locally (and if configured remotely). All of this happens transparently, so you don't have to worry
170
175
about it.
171
176
172
177
Although conceptually this is fairly straightforward, Nx optimizes this to make this experience good for you. For
@@ -209,7 +214,7 @@ it locally.
209
214
## In summary
210
215
211
216
- Nx is able to analyze your source code to create a Project Graph.
212
-
- Nx can use the project graph and information about projects’ targets to create a Task Graph.
217
+
- Nx can use the project graph and information about projects' targets to create a Task Graph.
213
218
- Nx is able to perform code-change analysis to create the smallest task graph for your PR.
214
219
- Nx supports computation caching to never execute the same computation twice. This computation cache is pluggable and
Copy file name to clipboardexpand all lines: docs/shared/concepts/module-federation/faster-builds.md
+5
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,8 @@
1
+
---
2
+
title: Faster Builds with Module Federation
3
+
description: Learn how Module Federation in Nx enables faster builds by splitting large SPAs into smaller remote applications while minimizing common downsides.
4
+
---
5
+
1
6
# Faster Builds with Module Federation
2
7
3
8
As applications grow, builds can become unacceptably slow, which leads to slow CI/CD pipelines and long dev-server
0 commit comments