cleanup(core): update the docs to be inline with nx 14 (#9851)
This commit is contained in:
parent
ec0f4b4173
commit
4990d050ae
@ -289,7 +289,7 @@ The following is an expanded version showing all options. Your `nx.json` will li
|
|||||||
},
|
},
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
"default": {
|
"default": {
|
||||||
"runner": "@nrwl/workspace/tasks-runners",
|
"runner": "nx/tasks-runners/default",
|
||||||
"options": {
|
"options": {
|
||||||
"cacheableOperations": ["build", "lint", "test", "e2e"]
|
"cacheableOperations": ["build", "lint", "test", "e2e"]
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ Tasks runners are invoked when you run `nx test`, `nx build`, `nx run-many`, `nx
|
|||||||
named "default" is used by default. Specify a different one like this `nx run-many --target=build --all --runner=another`.
|
named "default" is used by default. Specify a different one like this `nx run-many --target=build --all --runner=another`.
|
||||||
|
|
||||||
Tasks runners can accept different options. The following are the options supported
|
Tasks runners can accept different options. The following are the options supported
|
||||||
by `"@nrwl/workspace/tasks-runners"` and `"@nrwl/nx-cloud"`.
|
by `"nx/tasks-runners/default"` and `"@nrwl/nx-cloud"`.
|
||||||
|
|
||||||
- `cacheableOperations` defines the list of targets/operations that are cached by Nx.
|
- `cacheableOperations` defines the list of targets/operations that are cached by Nx.
|
||||||
- `parallel` defines the max number of targets ran in parallel (in older versions of Nx you had to
|
- `parallel` defines the max number of targets ran in parallel (in older versions of Nx you had to
|
||||||
@ -441,7 +441,7 @@ by `"@nrwl/workspace/tasks-runners"` and `"@nrwl/nx-cloud"`.
|
|||||||
{
|
{
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
"default": {
|
"default": {
|
||||||
"runner": "@nrwl/workspace/tasks-runners",
|
"runner": "nx/tasks-runners/default",
|
||||||
"options": {
|
"options": {
|
||||||
"cacheableOperations": ["build", "lint", "test", "e2e"],
|
"cacheableOperations": ["build", "lint", "test", "e2e"],
|
||||||
"runtimeCacheInputs": ["node -v"]
|
"runtimeCacheInputs": ["node -v"]
|
||||||
|
|||||||
@ -18,8 +18,7 @@ Watch this 3-min video to see how the command works and what next steps are:
|
|||||||
|
|
||||||
1. Add Nx to your package.json.
|
1. Add Nx to your package.json.
|
||||||
2. Create `nx.json`, containing all the necessary configuration for Nx.
|
2. Create `nx.json`, containing all the necessary configuration for Nx.
|
||||||
3. Set up a `tsconfig` file mapping if needed.
|
3. Set up Nx Cloud (if you chose "yes").
|
||||||
4. Set up Nx Cloud (if you chose "yes").
|
|
||||||
|
|
||||||
> If you are familiar with Turborepo, check out [this guide](/guides/turbo-and-nx). At this point, Nx can do anything Turbo can, and much more.
|
> If you are familiar with Turborepo, check out [this guide](/guides/turbo-and-nx). At this point, Nx can do anything Turbo can, and much more.
|
||||||
|
|
||||||
@ -147,7 +146,6 @@ Nx + Lerna:
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"lerna": "*",
|
"lerna": "*",
|
||||||
"@nrwl/workspace": "*",
|
|
||||||
"nx": "*"
|
"nx": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,16 +167,31 @@ many more. All the plugins are designed to work together and create a cohesive a
|
|||||||
In addition, Nx makes a lot of things much easier, like building large apps incrementally, distributing CI (no point in
|
In addition, Nx makes a lot of things much easier, like building large apps incrementally, distributing CI (no point in
|
||||||
doing caching unless you can do that), enforcing best practices, building design systems.
|
doing caching unless you can do that), enforcing best practices, building design systems.
|
||||||
|
|
||||||
## Troubleshooting
|
## Excluding Sources
|
||||||
|
|
||||||
The `add-nx-to-monorepo` command does its best to figure out what projects you have in the repo, but you can exclude
|
The `add-nx-to-monorepo` command does its best to figure out what projects you have in the repo. Similar to other tools, it looks at the `workspaces` property in the root `package.json` and tries to find all `package.json` files matching the globs. You can change those globs to exclude some projects. You can also exclude files by creating an `.nxignore` file, like this:
|
||||||
them by creating `.nxignore` file.
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
third_party # nx will ignore everything in the third-party dir
|
third_party # nx will ignore everything in the third-party dir
|
||||||
```
|
```
|
||||||
|
|
||||||
Nx can add a root tsconfig to your repo with something like this:
|
## Enabling JS Analysis
|
||||||
|
|
||||||
|
The `add-nx-to-monorepo` command adds the following to the generated `nx.json`. This disables JS analysis, such that Nx only analyzes `package.json` files like Lerna or Turborepo.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"pluginsConfig": {
|
||||||
|
"@nrwl/js": {
|
||||||
|
"analyzeSourceFiles": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
We do this because most existing Lerna monorepos have implicit dependencies between projects Lerna knows nothing about. By adding `"analyzeSourceFiles": false` we are trying to make sure that Nx sees the same project graph Lerna does, even though the graph is often incorrect.
|
||||||
|
|
||||||
|
You can remove the section in the config, which will enable the JS/TS analysis. In this case Nx will consider all import and require statements in your JS/TS files when creating its project graph. If you do that, you can also add the `paths` property to the root `tsconfig.base.json` (if you don't have this file, create it), which will tell Nx how to resolve imports.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -193,24 +206,6 @@ Nx can add a root tsconfig to your repo with something like this:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This tsconfig isn't used for building or testing. It's only used to teach Nx how to resolve imports, so Nx can do its
|
|
||||||
import source code analysis. If the path mappings are deduced incorrectly, feel free to change them.
|
|
||||||
|
|
||||||
Lerna only analyses package.json files. Nx does that, but in addition it also analyses all JavaScript/TypeScript files to make
|
|
||||||
sure it understands the project graph of your workspace.
|
|
||||||
|
|
||||||
If you want to disable the source code analysis, to make Nx match Lerna, add the following to your package.json:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"pluginsConfig": {
|
|
||||||
"@nrwl/js": {
|
|
||||||
"analyzeSourceFiles": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Real world examples of using add-nx-to-monorepo
|
## Real world examples of using add-nx-to-monorepo
|
||||||
|
|
||||||
### Speeding Up Facebook React Monorepo with Nx
|
### Speeding Up Facebook React Monorepo with Nx
|
||||||
|
|||||||
@ -32,10 +32,8 @@ package.json
|
|||||||
"scripts": {},
|
"scripts": {},
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nx": "12.8.0",
|
"nx": "14.0.0",
|
||||||
"@nrwl/workspace": "12.8.0",
|
"@nrwl/workspace": "14.0.0"
|
||||||
"@types/node": "14.14.33",
|
|
||||||
"typescript": "~4.3.5"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -44,11 +42,11 @@ package.json
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"extends": "@nrwl/workspace/presets/core.json",
|
"extends": "nx/presets/core.json",
|
||||||
"npmScope": "myorg",
|
"npmScope": "myorg",
|
||||||
"tasksRunnerOptions": {
|
"tasksRunnerOptions": {
|
||||||
"default": {
|
"default": {
|
||||||
"runner": "@nrwl/workspace/tasks-runners",
|
"runner": "nx/tasks-runners/default",
|
||||||
"options": {
|
"options": {
|
||||||
"cacheableOperations": ["build", "lint", "test", "e2e"]
|
"cacheableOperations": ["build", "lint", "test", "e2e"]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user