diff --git a/docs/generated/packages/nx.json b/docs/generated/packages/nx.json index b2d6636e77737..d6a19bc0aca10 100644 --- a/docs/generated/packages/nx.json +++ b/docs/generated/packages/nx.json @@ -327,7 +327,7 @@ }, "additionalProperties": true, "required": ["script"], - "examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"packages/frontend/dist\", \"packaged/frontend/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n", + "examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"{projectRoot}/dist\", \"{projectRoot}/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n", "presets": [] }, "description": "Run an NPM script using Nx.", diff --git a/docs/generated/packages/react-native.json b/docs/generated/packages/react-native.json index c078863e73b6e..a8c1d6d49d776 100644 --- a/docs/generated/packages/react-native.json +++ b/docs/generated/packages/react-native.json @@ -776,7 +776,7 @@ } }, "required": ["platform", "entryFile", "bundleOutput"], - "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"outputs\": [\"apps/mobile/build\"],\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\"\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\"\n }\n }\n }\n}\n```\n\n```bash\nnx run mobile:bundle-ios\nnx run mobile:bundle-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Bundle with sourcemap\" %}\nThe `sourcemapOutput` option allows you to specify the path of the source map relative to app folder:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/ios/main.map\",\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/android/main.map\",\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a dev/release bundle\" %}\n\nThe `dev` option determines whether to create a dev or release bundle. The default value is `true`, by setting it as `false`, warnings are disabled and the bundle is minified.\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"dev\": false\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"dev\": false\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a minified bundle\" %}\n\nThe `minify` option allows you to create a minified bundle:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"minify\": true\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"minify\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n", + "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"outputs\": [\"{projectRoot}/build\"],\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\"\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\"\n }\n }\n }\n}\n```\n\n```bash\nnx run mobile:bundle-ios\nnx run mobile:bundle-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Bundle with sourcemap\" %}\nThe `sourcemapOutput` option allows you to specify the path of the source map relative to app folder:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/ios/main.map\",\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"sourcemapOutput\": \"../../dist/apps/mobile/android/main.map\",\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a dev/release bundle\" %}\n\nThe `dev` option determines whether to create a dev or release bundle. The default value is `true`, by setting it as `false`, warnings are disabled and the bundle is minified.\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"dev\": false\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"dev\": false\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a minified bundle\" %}\n\nThe `minify` option allows you to create a minified bundle:\n\n```json\n \"bundle-ios\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"ios\",\n \"bundleOutput\": \"dist/apps/mobile/ios/main.jsbundle\",\n \"minify\": true\n }\n },\n \"bundle-android\": {\n \"executor\": \"@nrwl/react-native:bundle\",\n \"options\": {\n \"entryFile\": \"src/main.tsx\",\n \"platform\": \"android\",\n \"bundleOutput\": \"dist/apps/mobile/android/main.jsbundle\",\n \"minify\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n", "presets": [] }, "description": "Builds the JavaScript bundle for offline use.", @@ -811,7 +811,7 @@ } }, "required": [], - "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:build-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Build with custom gradleTask\" %}\nThe `gradleTask` option accepts any custom gradle task, such as `assembleDebug`, `assembleRelease`, `bundleDebug`, `bundleRelease`:\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"gradleTask\": \"assembleDebug\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a build with apk format\" %}\n\nThe `apk` option allows you determine the format of android build. If set as true, it will create a build with `.apk` extension under apk folder; if set as false, it will create with `.aab` extension under bundle folder.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"apk\": true\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Build for debug/release\" %}\n\nIf set `debug` option as `true`, it will create a debug build; if set as `false`, it will create a release build.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"apps/mobile/android/app/build/outputs/bundle\",\n \"apps/mobile/android/app/build/outputs/apk\"\n ],\n \"options\": {\n \"debug\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n", + "examplesFile": "`project.json`:\n\n```json\n{\n \"name\": \"mobile\",\n //...\n \"targets\": {\n //...\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {}\n }\n }\n}\n```\n\n```bash\nnx run mobile:build-android\n```\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Build with custom gradleTask\" %}\nThe `gradleTask` option accepts any custom gradle task, such as `assembleDebug`, `assembleRelease`, `bundleDebug`, `bundleRelease`:\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"gradleTask\": \"assembleDebug\"\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Create a build with apk format\" %}\n\nThe `apk` option allows you determine the format of android build. If set as true, it will create a build with `.apk` extension under apk folder; if set as false, it will create with `.aab` extension under bundle folder.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"apk\": true\n }\n }\n```\n\n{% /tab %}\n{% tab label=\"Build for debug/release\" %}\n\nIf set `debug` option as `true`, it will create a debug build; if set as `false`, it will create a release build.\n\n```json\n \"build-android\": {\n \"executor\": \"@nrwl/react-native:build-android\",\n \"outputs\": [\n \"{projectRoot}/build/outputs/bundle\",\n \"{projectRoot}/build/outputs/apk\"\n ],\n \"options\": {\n \"debug\": true\n }\n }\n```\n\n{% /tab %}\n{% /tabs %}\n\n---\n", "presets": [] }, "description": "Release Build for Android.", diff --git a/docs/generated/packages/workspace.json b/docs/generated/packages/workspace.json index a901d89fe750f..7b56a17fca3fc 100644 --- a/docs/generated/packages/workspace.json +++ b/docs/generated/packages/workspace.json @@ -853,7 +853,7 @@ }, "additionalProperties": true, "required": ["script"], - "examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"packages/frontend/dist\", \"packaged/frontend/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n", + "examplesFile": "`workspace.json`:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n\n```bash\nnx run frontend:build\n```\n\nThe `build` target is going to run `npm run build-my-project` (or `yarn build-my-project`) in the `packages/frontend` directory.\n\n#### Caching Artifacts\n\nBy default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/dist`, `packages/frontend/build`, `packages/frontend/public`. If your npm script writes files to other places, you can override the list of cached outputs as follows:\n\n```json\n\"frontend\": {\n \"root\": \"packages/frontend\",\n \"targets\": {\n \"build\": {\n \"executor\": \"nx:run-script\",\n \"outputs\": [\"{projectRoot}/dist\", \"{projectRoot}/docs\"],\n \"options\": {\n \"script\": \"build-my-project\"\n }\n }\n }\n}\n```\n", "presets": [] }, "description": "Run an NPM script using Nx.", diff --git a/docs/shared/core-features/cache-task-results.md b/docs/shared/core-features/cache-task-results.md index 891d0f6e4ec3d..19fcf6e7ec4ef 100644 --- a/docs/shared/core-features/cache-task-results.md +++ b/docs/shared/core-features/cache-task-results.md @@ -31,28 +31,41 @@ the result of the test run. Now, run the following command twice. The second time the operation will be instant: -```{% command="nx test header"%} -> nx run header:test [existing outputs match the cache, left as is] +```shell +nx build header +``` + +```{% command="nx build header"%} +> nx run header:build [local cache] + + +> header@0.0.0 build +> rimraf dist && rollup --config + -> header@0.0.0 test -> jest +src/index.tsx → dist... +created dist in 858ms -PASS src/Header.spec.tsx - ✓ renders header (14 ms) + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— -Test Suites: 1 passed, 1 total -Tests: 1 passed, 1 total -Snapshots: 0 total -Time: 0.528 s, estimated 2 s -Ran all test suites. + > NX Successfully ran target build for project header (13ms) -——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + Nx read the output from the cache instead of running the command for 1 out of 1 tasks. +``` + +## Replaying from Cache + +When Nx determines that the inputs for a task have not changed, it recreates the outputs of that task as if it actually ran on your machine - but much faster. The outputs of a cached task include both the terminal output and the files created in the defined `output` directories for that task. -> NX Successfully ran target test for project header (4ms) +You can test this out by deleting the `dist` folder that the `header:build` task outputs to and then running `nx build header` again. The cached task will replay instantly and the correct files will be present in the `dist` folder. -Nx read the output from the cache instead of running the command for 1 out of 1 tasks. +```treeview +header/ +└── dist/ <-- this folder gets recreated ``` +If your task creates output artifacts in a different location, you can [change the output folder(s)](/reference/project-configuration#outputs) that are cached. You can also [customize which inputs](/more-concepts/customizing-inputs) will invalidate the cache if they are changed. + ## Advanced Caching For a more in-depth understanding of the caching implementation and to fine-tune the caching for your repo, read [How Caching Works](/concepts/how-caching-works). @@ -75,6 +88,76 @@ You can connect your workspace to Nx Cloud by running: npx nx connect-to-nx-cloud ``` +```{% command="npx nx connect-to-nx-cloud"%} +✔ Enable distributed caching to make your CI faster · Yes + +> NX Generating @nrwl/nx-cloud:init + +UPDATE nx.json + + > NX Distributed caching via Nx Cloud has been enabled + + In addition to the caching, Nx Cloud provides config-free distributed execution, + UI for viewing complex runs and GitHub integration. Learn more at https://nx.app + + Your workspace is currently unclaimed. Run details from unclaimed workspaces can be viewed on cloud.nx.app by anyone + with the link. Claim your workspace at the following link to restrict access. + + https://cloud.nx.app/orgs/workspace-setup?accessToken=YOURACCESSTOKEN +``` + +To see the remote cache in action, run: + +```shell +nx build header && nx reset && nx build header +``` + +```{% command="nx build header && nx reset && nx build header"%} +> nx run header:build + +> header@0.0.0 build +> rimraf dist && rollup --config + +src/index.tsx → dist... +created dist in 786ms + + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + > NX Successfully ran target build for project header (2s) + + See logs and investigate cache misses at https://cloud.nx.app/runs/k0HDHACpL8 + + + > NX Resetting the Nx workspace cache and stopping the Nx Daemon. + + This might take a few minutes. + + + > NX Daemon Server - Stopped + + + > NX Successfully reset the Nx workspace. + + +> nx run header:build [remote cache] + + +> header@0.0.0 build +> rimraf dist && rollup --config + + +src/index.tsx → dist... +created dist in 786ms + + ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— + + > NX Successfully ran target build for project header (664ms) + + Nx read the output from the cache instead of running the command for 1 out of 1 tasks. + + Nx Cloud made it possible to reuse header: https://nx.app/runs/P0X6ZGTkqZ +``` + ## See Also: - [Nx Cloud Documentation](/nx-cloud/intro/what-is-nx-cloud) diff --git a/docs/shared/core-features/distribute-task-execution.md b/docs/shared/core-features/distribute-task-execution.md index 276859dfc2ff1..3bd6cdb43faa6 100644 --- a/docs/shared/core-features/distribute-task-execution.md +++ b/docs/shared/core-features/distribute-task-execution.md @@ -1,8 +1,18 @@ # Distribute Task Execution (DTE) -Nx supports running commands across multiple machines. You can either set it up by hand (by using batching or binning) or use Nx Cloud. +Nx speeds up your average CI time with [caching](/core-features/cache-task-results) and the [affected command](/concepts/affected). But neither of these features help with the worst case scenario. When something at the core of your repo has been modified and every task needs to be run in CI, the only way to improve the performance is by adding more agent jobs and efficiently parallelizing the tasks. -[Read the comparison of the two approaches.](https://blog.nrwl.io/distributing-ci-binning-and-distributed-task-execution-632fe31a8953?source=friends_link&sk=5120b7ff982730854ed22becfe7a640a) +The most obvious way to parallelize tasks is to split tasks up by type: running all tests on one job, all builds on another and all lint tasks on a third. This strategy is called binning. This can be made difficult if some test tasks have build tasks as prerequisites, but assuming you figure out some way to handle that, a typical set up can look like the diagram below. Here the test tasks are delayed until all necessary build artifacts are ready, but the build and lint tasks can start right away. + +![CI using binning](../images/dte/binning.svg) + +The problem with the binning approach is you'll end up with some idle time on one or more jobs. Nx's distributed task execution reduces that idle time to the minimum possible by assigning each individual task to agent jobs based on the task's average run time. Nx also guarantees that tasks are executed in the correct order and uses distributed caching to make sure that build artifacts from previous tasks are present on every agent job that needs them. + +When you set up Nx's distributed task execution, your task graph will look more like this: + +![CI using DTE](../images/dte/3agents.svg) + +And not only will CI finish faster, but the debugging experience is the same as if you ran all of your CI on a single job. That's because Nx uses distributed caching to recreate all of the logs and build artifacts on the main job. ## Set up @@ -20,10 +30,10 @@ The `--ci` flag can be `github`, `circleci` or `azure`. For more details on sett ## CI Execution Flow -There are two main parts to the CI set up: +Distributed task execution can work on any CI provider. You are responsible for launching jobs in your CI system. Nx Cloud then coordinates the way those jobs work together. There are two different kinds of jobs that you'll need to create in your CI system. -1. The main job that controls what is going to be executed -2. The agent jobs that actually execute the tasks +1. One main job that controls what is going to be executed +2. Multiple agent jobs that actually execute the tasks The main job execution flow looks like this: diff --git a/docs/shared/core-features/run-tasks.md b/docs/shared/core-features/run-tasks.md index ff29c0400a918..5bd43a870de93 100644 --- a/docs/shared/core-features/run-tasks.md +++ b/docs/shared/core-features/run-tasks.md @@ -85,7 +85,7 @@ the name of the target. ## Run Tasks Affected by a PR -You can also run a command for all the projects affected in your PR like this: +You can also run a command for all the projects affected by your PR like this: ```shell npx nx affected --target=test diff --git a/docs/shared/guides/setup-incremental-builds-angular.md b/docs/shared/guides/setup-incremental-builds-angular.md index b139232948f62..22d0f7b08e4f1 100644 --- a/docs/shared/guides/setup-incremental-builds-angular.md +++ b/docs/shared/guides/setup-incremental-builds-angular.md @@ -50,7 +50,7 @@ builds scenario: "build": { "executor": "@nrwl/angular:ng-packagr-lite", "outputs": [ - "dist/libs/my-lib" + "{workspaceRoot}/dist/libs/my-lib" ], "options": { ... @@ -255,7 +255,7 @@ depends on must also be `build-base`: "build-base": { "executor": "@nrwl/angular:ng-packagr-lite", "outputs": [ - "dist/libs/my-lib" + "{workspaceRoot}/dist/libs/my-lib" ], "options": { ... diff --git a/docs/shared/guides/using-tailwind-css-with-angular-projects.md b/docs/shared/guides/using-tailwind-css-with-angular-projects.md index 5bdaf5bfebf96..b55dc9d32d5ad 100644 --- a/docs/shared/guides/using-tailwind-css-with-angular-projects.md +++ b/docs/shared/guides/using-tailwind-css-with-angular-projects.md @@ -444,7 +444,7 @@ Next, you need to configure your project to build the theme when you build the l ... "build-angular": { "executor": "@nrwl/angular:package", - "outputs": ["dist/libs/lib1"], + "outputs": ["{workspaceRoot}/dist/libs/lib1"], "options": { "project": "libs/lib1/ng-package.json", "tailwindConfig": "libs/lib1/tailwind.config.js" @@ -461,7 +461,7 @@ Next, you need to configure your project to build the theme when you build the l }, "build-lib": { "executor": "nx:run-commands", - "outputs": ["dist/libs/lib1"], + "outputs": ["{workspaceRoot}/dist/libs/lib1"], "configurations": { "production": { "commands": [ @@ -480,7 +480,7 @@ Next, you need to configure your project to build the theme when you build the l }, "build": { "executor": "nx:run-commands", - "outputs": ["dist/libs/lib1"], + "outputs": ["{workspaceRoot}/dist/libs/lib1"], "configurations": { "production": { "commands": [ diff --git a/docs/shared/images/dte/3agents.svg b/docs/shared/images/dte/3agents.svg new file mode 100644 index 0000000000000..a35c23215b35c --- /dev/null +++ b/docs/shared/images/dte/3agents.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/shared/images/dte/binning.svg b/docs/shared/images/dte/binning.svg new file mode 100644 index 0000000000000..9881eba19c066 --- /dev/null +++ b/docs/shared/images/dte/binning.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/shared/mental-model.md b/docs/shared/mental-model.md index 5a6243903870d..a1655234d3ae2 100644 --- a/docs/shared/mental-model.md +++ b/docs/shared/mental-model.md @@ -60,7 +60,7 @@ Let’s look at the test target relying on its dependencies. { "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/apps/app1"], + "outputs": ["{workspaceRoot}/coverage/apps/app1"], "dependsOn": ["^test"], "options": { "jestConfig": "apps/app1/jest.config.js", diff --git a/docs/shared/node-tutorial/3-task-running.md b/docs/shared/node-tutorial/3-task-running.md index ebeb6e889203a..0e94c244aa4e8 100644 --- a/docs/shared/node-tutorial/3-task-running.md +++ b/docs/shared/node-tutorial/3-task-running.md @@ -39,7 +39,7 @@ Here's the `project.json` file for your `products-data-client` project: }, "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/products-data-client"], + "outputs": ["{workspaceRoot}/coverage/libs/products-data-client"], "options": { "jestConfig": "libs/products-data-client/jest.config.ts", "passWithNoTests": true diff --git a/docs/shared/node-tutorial/4-workspace-optimization.md b/docs/shared/node-tutorial/4-workspace-optimization.md index ea808ef563780..3606b25771771 100644 --- a/docs/shared/node-tutorial/4-workspace-optimization.md +++ b/docs/shared/node-tutorial/4-workspace-optimization.md @@ -128,7 +128,7 @@ Outputs are defined for every target in your workspace: }, "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/products-data-client"], + "outputs": ["{workspaceRoot}/coverage/libs/products-data-client"], "options": { "jestConfig": "libs/products-data-client/jest.config.ts", "passWithNoTests": true diff --git a/docs/shared/react-tutorial/3-task-running.md b/docs/shared/react-tutorial/3-task-running.md index 685f5c2e8c10d..9a1ecdb8b4660 100644 --- a/docs/shared/react-tutorial/3-task-running.md +++ b/docs/shared/react-tutorial/3-task-running.md @@ -31,7 +31,7 @@ Here's the `project.json` file for your `common-ui` project: }, "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/common-ui"], + "outputs": ["{workspaceRoot}/coverage/libs/common-ui"], "options": { "jestConfig": "libs/common-ui/jest.config.ts", "passWithNoTests": true diff --git a/docs/shared/react-tutorial/4-workspace-optimization.md b/docs/shared/react-tutorial/4-workspace-optimization.md index d85e358b1bca2..e56cc202911f5 100644 --- a/docs/shared/react-tutorial/4-workspace-optimization.md +++ b/docs/shared/react-tutorial/4-workspace-optimization.md @@ -84,7 +84,7 @@ Outputs are defined for every target in your workspace: }, "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/products"], + "outputs": ["{workspaceRoot}/coverage/libs/products"], "options": { "jestConfig": "libs/products/jest.config.ts", "passWithNoTests": true diff --git a/docs/shared/recipes/use-executor-configurations.md b/docs/shared/recipes/use-executor-configurations.md index a09d22343d181..1223b583f1891 100644 --- a/docs/shared/recipes/use-executor-configurations.md +++ b/docs/shared/recipes/use-executor-configurations.md @@ -6,7 +6,7 @@ The `configurations` property provides extra sets of values that will be merged { "build": { "executor": "@nrwl/js:tsc", - "outputs": ["dist/libs/mylib"], + "outputs": ["{workspaceRoot}/dist/libs/mylib"], "dependsOn": ["^build"], "options": { "tsConfig": "libs/mylib/tsconfig.lib.json", diff --git a/docs/shared/reference/nx-json.md b/docs/shared/reference/nx-json.md index c9cbd70acf8eb..de40b0099ad10 100644 --- a/docs/shared/reference/nx-json.md +++ b/docs/shared/reference/nx-json.md @@ -175,7 +175,7 @@ Another target default you can configure is `outputs`: { "targetDefaults": { "build": { - "outputs": ["./custom-dist"] + "outputs": ["{projectRoot}/custom-dist"] } } } diff --git a/docs/shared/reference/project-configuration.md b/docs/shared/reference/project-configuration.md index 2bc8432c28a40..72fbf30fecad5 100644 --- a/docs/shared/reference/project-configuration.md +++ b/docs/shared/reference/project-configuration.md @@ -56,22 +56,18 @@ You can add Nx-specific configuration as follows: { "name": "mylib", "scripts": { - "test: "jest", + "test": "jest", "build": "tsc -p tsconfig.lib.json" // the actual command here is arbitrary }, "nx": { "namedInputs": { - "default": [ - "{projectRoot}/**/*" - ], - "production": [ - "!{projectRoot}/**/*.spec.tsx" - ] + "default": ["{projectRoot}/**/*"], + "production": ["!{projectRoot}/**/*.spec.tsx"] }, "targets": { "build": { "inputs": ["production", "^production"], - "outputs": ["dist/libs/mylib"], + "outputs": ["{workspaceRoot}/dist/libs/mylib"], "dependsOn": ["^build"] }, "test": { @@ -107,7 +103,7 @@ You can add Nx-specific configuration as follows: "build": { "executor": "@nrwl/js:tsc", "inputs": ["production", "^production"], - "outputs": ["dist/libs/mylib"], + "outputs": ["{workspaceRoot}/dist/libs/mylib"], "dependsOn": ["^build"], "options": {} } @@ -192,7 +188,7 @@ sources (non-test sources) of its dependencies. In other words, it treats test s ### outputs -Targets may define outputs to tell Nx where the target is going to create file artifacts that Nx should cache. `"outputs": ["dist/libs/mylib"]` tells Nx where the `build` target is going to create file artifacts. +Targets may define outputs to tell Nx where the target is going to create file artifacts that Nx should cache. `"outputs": ["{workspaceRoot}/dist/libs/mylib"]` tells Nx where the `build` target is going to create file artifacts. This configuration is usually not needed. Nx comes with reasonable defaults (imported in `nx.json`) which implement the configuration above. @@ -203,7 +199,10 @@ Usually, a target writes to a specific directory or a file. The following instru ```json { "build": { - "outputs": ["dist/libs/mylib", "build/libs/mylib/main.js"] + "outputs": [ + "{workspaceRoot}/dist/libs/mylib", + "{workspaceRoot}/build/libs/mylib/main.js" + ] } } ``` @@ -215,10 +214,10 @@ Sometimes, multiple targets might write to the same directory. When possible it ```json { "build-js": { - "outputs": ["dist/libs/mylib/js"] + "outputs": ["{workspaceRoot}/dist/libs/mylib/js"] }, "build-css": { - "outputs": ["dist/libs/mylib/css"] + "outputs": ["{workspaceRoot}/dist/libs/mylib/css"] } } ``` @@ -228,10 +227,10 @@ But if the above is not possible, globs can be specified as outputs to only cach ```json { "build-js": { - "outputs": ["dist/libs/mylib/**/*.js"] + "outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.js"] }, "build-css": { - "outputs": ["dist/libs/mylib/**/*.css"] + "outputs": ["{workspaceRoot}/dist/libs/mylib/**/*.css"] } } ``` diff --git a/packages/nx/docs/run-script-examples.md b/packages/nx/docs/run-script-examples.md index ddfc4c77bf806..9b33160d50211 100644 --- a/packages/nx/docs/run-script-examples.md +++ b/packages/nx/docs/run-script-examples.md @@ -30,7 +30,7 @@ By default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/di "targets": { "build": { "executor": "nx:run-script", - "outputs": ["packages/frontend/dist", "packaged/frontend/docs"], + "outputs": ["{projectRoot}/dist", "{projectRoot}/docs"], "options": { "script": "build-my-project" } diff --git a/packages/react-native/docs/build-android-examples.md b/packages/react-native/docs/build-android-examples.md index 8ddeb7d7b33a3..464236bd25f38 100644 --- a/packages/react-native/docs/build-android-examples.md +++ b/packages/react-native/docs/build-android-examples.md @@ -9,8 +9,8 @@ "build-android": { "executor": "@nrwl/react-native:build-android", "outputs": [ - "apps/mobile/android/app/build/outputs/bundle", - "apps/mobile/android/app/build/outputs/apk" + "{projectRoot}/build/outputs/bundle", + "{projectRoot}/build/outputs/apk" ], "options": {} } @@ -32,8 +32,8 @@ The `gradleTask` option accepts any custom gradle task, such as `assembleDebug`, "build-android": { "executor": "@nrwl/react-native:build-android", "outputs": [ - "apps/mobile/android/app/build/outputs/bundle", - "apps/mobile/android/app/build/outputs/apk" + "{projectRoot}/build/outputs/bundle", + "{projectRoot}/build/outputs/apk" ], "options": { "gradleTask": "assembleDebug" @@ -50,8 +50,8 @@ The `apk` option allows you determine the format of android build. If set as tru "build-android": { "executor": "@nrwl/react-native:build-android", "outputs": [ - "apps/mobile/android/app/build/outputs/bundle", - "apps/mobile/android/app/build/outputs/apk" + "{projectRoot}/build/outputs/bundle", + "{projectRoot}/build/outputs/apk" ], "options": { "apk": true @@ -68,8 +68,8 @@ If set `debug` option as `true`, it will create a debug build; if set as `false` "build-android": { "executor": "@nrwl/react-native:build-android", "outputs": [ - "apps/mobile/android/app/build/outputs/bundle", - "apps/mobile/android/app/build/outputs/apk" + "{projectRoot}/build/outputs/bundle", + "{projectRoot}/build/outputs/apk" ], "options": { "debug": true diff --git a/packages/react-native/docs/bundle-examples.md b/packages/react-native/docs/bundle-examples.md index 805335fbd4614..5372b59dd8dbc 100644 --- a/packages/react-native/docs/bundle-examples.md +++ b/packages/react-native/docs/bundle-examples.md @@ -8,7 +8,7 @@ //... "bundle-ios": { "executor": "@nrwl/react-native:bundle", - "outputs": ["apps/mobile/build"], + "outputs": ["{projectRoot}/build"], "options": { "entryFile": "src/main.tsx", "platform": "ios", diff --git a/packages/workspace/docs/run-script-examples.md b/packages/workspace/docs/run-script-examples.md index ddfc4c77bf806..9b33160d50211 100644 --- a/packages/workspace/docs/run-script-examples.md +++ b/packages/workspace/docs/run-script-examples.md @@ -30,7 +30,7 @@ By default, Nx is going to cache `dist/packages/frontend`, `packages/frontend/di "targets": { "build": { "executor": "nx:run-script", - "outputs": ["packages/frontend/dist", "packaged/frontend/docs"], + "outputs": ["{projectRoot}/dist", "{projectRoot}/docs"], "options": { "script": "build-my-project" }