1.5 KiB
How the Project Graph is Built
Nx creates a graph of all the dependencies between projects in your workspace using three sources of information:
-
Package dependencies defined in the
package.jsonfile for each project.If the
myapp/package.jsonfile has this dependency:{ "dependencies": { "@myorg/awesome-library": "*" } }Then
my-appdepends onawesome-library.Note: We typically use
*for the dependency instead of a specific version because we want to depend on the version of the library as it currently exists in the repo. -
Typescript
importstatements referencing a particular project's path aliasFor instance, if a file in
my-apphas this code:import { something } from '@myorg/awesome-library';Then
my-appdepends onawesome-libraryThis can be turned on or off with the
analyzeSourceFilesflag. -
Manually created
implicitDependenciesin the project configuration file.If your project configuration has this content:
{% tabs %} {% tab label="package.json" %}
{
"name": "myapp",
"nx": {
"implicitDependencies": ["some-api"]
}
}
{% /tab %} {% tab label="project.json" %}
{
"root": "/libs/myapp",
"implicitDependencies": ["some-api"]
}
{% /tab %} {% /tabs %}
Then my-app depends on some-api.