diff --git a/docs/shared/concepts/turbo-and-nx.md b/docs/shared/concepts/turbo-and-nx.md index 65872c06f0fc6..ea13f8cc89808 100644 --- a/docs/shared/concepts/turbo-and-nx.md +++ b/docs/shared/concepts/turbo-and-nx.md @@ -8,7 +8,7 @@ Note that the relationship between Nx and Turborepo isn’t the same as with Nx We do our best to be unbiased, but, of course you should do your own research. Read the docs, try things out and build your own opinion. -We clearly separate Nx (the open source tool) and [Nx Cloud](https://nx.app) (the SAAS product). Turborepo doesn’t have such a separation. Hence, in this guide we compare Turborepo with Nx+Nx Cloud (so it’s apples to apples). That said, you don’t have to use Nx Cloud to get features such as remote caching and distributed task execution. We provide public APIs so you can build your own, if you'd prefer not to use Nx Cloud. +We clearly separate Nx (the open source tool) and [Nx Cloud](https://nx.app) (the SAAS product). Turborepo doesn’t have such a separation. Hence, in this guide we compare Turborepo with Nx+Nx Cloud (so it’s apples to apples). We are going to compare the tools in three different ways: **features**, **tech and performance**, and **community**. @@ -80,7 +80,6 @@ A crucial feature in Nx is the ability to not only parallelize your tasks on a s - **Turborepo doesn’t support it.** The best thing you can do when using Turborepo is binning/sharding, and that doesn’t work for non-trivial workspaces. - **Distributed task execution has a significantly higher impact on the ability to scale the repo than the computation cache.** You can scale without the cache, you cannot scale without the distribution. - This is the biggest feature related to performance and scaling that Turborepo is missing. And it’s by far the hardest one to build. -- As with the rest of Nx, you can build your own version of the distributed task execution given the provided public API. If you choose not to implement your own version of the remote cache, you can use Nx Cloud. There is an [on-prem version of Nx Cloud](https://nx.app/private-cloud), so you have full control over where the artifacts are stored. If you want to learn more, check out our article on [Distributing CI - Binning and Distributed Task Execution](https://blog.nrwl.io/distributing-ci-binning-and-distributed-task-execution-632fe31a8953) @@ -147,7 +146,7 @@ Benchmarking is hard because a lot depends on what you are trying to run, in wha This is the result: ![nx and turbo benchmark](/shared/concepts/turbo-nx-perf.gif) -Nx is 9.4 times faster on the latest MBP. We have made several changes to [the benchmark](https://github.com/vsavkin/large-monorepo/) since it was released (removed the usage `npx` and addressed other concerns folks had), but the result remained roughly the same. Please check out the benchmark. +Nx is 4 times faster on the latest MBP. We have made several changes to [the benchmark](https://github.com/vsavkin/large-monorepo/) since it was released (removed the usage `npx` and addressed other concerns folks had), but the result remained roughly the same. Please check out the benchmark. Why is it faster? Nx is in many ways akin to React in that it's doing tree diffing when restoring files from the cache. If the right files are in the right place, Nx won't touch them. Turbo blows everything away every time. Nx's version isn't just faster, it's also more useful (again similarly to tree diffing in React). Blowing everything away on every restoration means that if any tools watch the folders (which is common when you build large apps or build microfrontends), they are going to get confused or triggered for no reason. This is similar to how recreating the DOM from scratch isn't just slower, but results in worse UX. But even if you disable tree-diffing and make Nx do what Turbo does, it is still 1.7 times faster. @@ -163,7 +162,7 @@ The one advantage Turbo's Go implementation has, is that any time you run an Nx **The reason why we stuck with TypeScript is that our focus was always on extensibility.** If the rise of VSCode taught us anything, it is that it’s easier to extend things when they are written in JavaScript/TypeScript. Also, 5 years of **working with Fortune 500 companies** clearly showed us that **extensibility is key**! -It’s also worth noting that the backend of Nx Cloud is written in Kotlin. This is because the only contributors to our API, work at Nrwl, and we decided it was the best technology for the job. +It’s also worth noting that the backend of Nx Cloud is written in Kotlin. This is because the only contributors to our API work at Nx, and we decided it was the best technology for the job. ## Community @@ -173,8 +172,6 @@ Nx was released in 2016. Turborepo was open sourced in December of 2021. Turbore - There are about 1 million+ unique [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console) (a plugin for VSCode) installations. - There is a rich ecosystem of [third-party plugins](/plugin-registry). -From day 1 Nx has always been an **MIT-licensed open source project**, and we did everything to make sure companies using Nx won’t end up in the vendor lock-in. We clearly separated Nx the open source project and Nx Cloud the SAAS product. For instance, Nx Cloud is built using the public APIs Nx provides (you can build your own and some companies do). Nx Cloud docs are on a separate domain etc. - ## Switch to Nx If you're ready to switch from Turborepo to Nx, the [migration process is fully documented](/recipes/adopting-nx/from-turborepo). diff --git a/docs/shared/migration/from-turborepo.md b/docs/shared/migration/from-turborepo.md index fc226f6dd1ce5..75b9383317034 100644 --- a/docs/shared/migration/from-turborepo.md +++ b/docs/shared/migration/from-turborepo.md @@ -100,57 +100,61 @@ Creating the equivalent configuration with Nx yields the following files: For each `turbo.json` configuration property, the equivalent Nx property is listed. -| **Global Configuration:** | | -| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -| `globalDependencies` | add to the [`sharedGlobals` `namedInput`](/recipes/running-tasks/configure-inputs) | -| `globalEnv` | add to the [`sharedGlobals` `namedInput`](/recipes/running-tasks/configure-inputs) as an [`env` input](/reference/inputs#environment-variables) | -| `globalPassThroughEnv` | N/A. See [Defining Environment Variables](/recipes/tips-n-tricks/define-environment-variables) | - -| **Task Configuration:** | | -| ---------------------------- | ---------------------------------------------------------------------------------------------- | -| `extends` | N/A. The project configurations will always extend the `targetDefaults` defined in `nx.json`. | -| `tasks[task].dependsOn` | [Same syntax](/reference/project-configuration#dependson). | -| `tasks[task].env` | Define [env `inputs`](/reference/inputs#environment-variables) | -| `tasks[task].passThroughEnv` | N/A. See [Defining Environment Variables](/recipes/tips-n-tricks/define-environment-variables) | -| `tasks[task].outputs` | [Same syntax](/reference/project-configuration#outputs). | -| `tasks[task].cache` | [Same syntax](/reference/project-configuration#cache) | -| `tasks[task].inputs` | [Same syntax](/reference/inputs#source-files). | -| `tasks[task].outputLogs` | Use the [`--output-style` command line flag](/nx-api/nx/documents/run-many#output-style) | -| `tasks[task].persistent` | N/A. | -| `tasks[task].interactive` | N/A. | +| **Global Configuration:** | | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `cacheDir` | Set in [`cacheDirectory`](/reference/nx-json#task-options) | +| `deamon` | Use [`NX_DAEMON=false` or set `useDaemonProcess: false`](/concepts/nx-daemon#turning-it-off) in `nx.json` | +| `envMode` | Nx core does not block any environment variables. There are [React](/recipes/react/use-environment-variables-in-react) and [Angular](/recipes/angular/use-environment-variables-in-angular) build executors that handle environment variables in a customized way. | +| `globalDependencies` | add to the [`sharedGlobals` `namedInput`](/recipes/running-tasks/configure-inputs) | +| `globalEnv` | add to the [`sharedGlobals` `namedInput`](/recipes/running-tasks/configure-inputs) as an [`env` input](/reference/inputs#environment-variables) | +| `globalPassThroughEnv` | N/A. See [Defining Environment Variables](/recipes/tips-n-tricks/define-environment-variables) | +| `remoteCache` | See [Nx Replay](/ci/features/remote-cache) | +| `ui` | Use [`--output-style`](/nx-api/nx/documents/run-many#output-style) | +| **Task Configuration:** | | +| ---------------------------- | ---------------------------------------------------------------------------------------------- | +| `extends` | N/A. The project configurations will always extend the `targetDefaults` defined in `nx.json`. | +| `tasks[task].dependsOn` | [Same syntax](/reference/project-configuration#dependson). | +| `tasks[task].env` | Define [env `inputs`](/reference/inputs#environment-variables) | +| `tasks[task].passThroughEnv` | N/A. See [Defining Environment Variables](/recipes/tips-n-tricks/define-environment-variables) | +| `tasks[task].outputs` | [Same syntax](/reference/project-configuration#outputs). | +| `tasks[task].cache` | [Same syntax](/reference/project-configuration#cache) | +| `tasks[task].inputs` | [Same syntax](/reference/inputs#source-files). | +| `tasks[task].outputLogs` | Use the [`--output-style` command line flag](/nx-api/nx/documents/run-many#output-style) | +| `tasks[task].persistent` | N/A. | +| `tasks[task].interactive` | N/A. | ## Command Equivalents -| | | -| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `turbo run test lint build` | [`nx run-many -t test lint build`](/nx-api/nx/documents/run-many) | -| `--cache-dir` | Set in [`nx.json` under `cacheDirectory`](/reference/nx-json#task-options) | -| `--concurrency` | [`--parallel`](/nx-api/nx/documents/run-many#parallel) | -| `--continue` | [Use `--nx-bail`](/nx-api/nx/documents/run-many#nx-bail) with the inverse value | -| `--cwd` | Available when using the [`run-commands` executor](/nx-api/nx/executors/run-commands#cwd) | -| `--dry-run` | N/A. Nx has `--dry-run` for `nx generate` but not for running tasks. | -| `--env-mode` | N/A | -| `--filter` | Use [`-p admin-*` or `-p tag:api-*`](/nx-api/nx/documents/run-many#projects). Also see [`nx affected`](/nx-api/nx/documents/affected). | -| `--graph` | [Same syntax](/nx-api/nx/documents/run-many#graph) or [`nx graph`](/nx-api/nx/documents/dep-graph) for the entire graph | -| `--force` | [`nx reset`](/nx-api/nx/documents/reset) and then run the command again | -| `--global-deps` | Use [`inputs` in the `nx.json`](/recipes/running-tasks/configure-inputs) or project configuration | -| `--framework-inference` | Nx knows if you're using a particular framework if you use an executor for that framework. | -| `--ignore` | Use an [`.nxignore` file](/reference/nxignore) (or `.gitignore`) | -| `--log-order` | Use [`--output-style`](/nx-api/nx/documents/run-many#output-style) | -| `--no-cache` | Use [`--skip-nx-cache`](/nx-api/nx/documents/run-many#skip-nx-cache) | -| `--no-daemon` | Use [`NX_DAEMON=false` or set `useDaemonProcess: false`](/concepts/nx-daemon#turning-it-off) in `nx.json` | -| `--output-logs` | Use [`--output-style`](/nx-api/nx/documents/run-many#output-style) | -| `--only` | N/A | -| `--parallel` | N/A | -| `--remote-only` | N/A. Can [ignore the remote cache](/ci/features/remote-cache#skipping-cloud-cache) with `--no-cloud`. | -| `--summarize` | N/A | -| `--token` | Set the [Nx Cloud CI Access Token](/ci/recipes/security/access-tokens#setting-ci-access-tokens) or as an environment variable (`NX_CLOUD_ACCESS_TOKEN`) | -| `--team` | See `--token` for choosing a different Nx Cloud workspace. You can [use `--runner`](/nx-api/nx/documents/run-many#runner) to choose a different runner defined in the `nx.json` file. | -| `--preflight` | N/A | -| `--trace` | N/A. [`--verbose`](/nx-api/nx/documents/run-many#verbose) for more logging. | -| `--heap` | N/A. [`--verbose`](/nx-api/nx/documents/run-many#verbose) for more logging. | -| `--cpuprofile` | Use [`NX_PROFILE=profile.json`](/troubleshooting/performance-profiling). | -| `--verbosity` | Use [`--verbose`](/nx-api/nx/documents/run-many#verbose) | -| `turbo gen` | [Use `nx generate`](/nx-api/nx/documents/generate) | -| `turbo login` | No need. [Create an Nx Cloud account](/nx-api/nx/documents/connect-to-nx-cloud) once to set up Nx Cloud. | -| `turbo link` | [Create an Nx Cloud account](/nx-api/nx/documents/connect-to-nx-cloud) | +| | | +| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `turbo run test lint build` | [`nx run-many -t test lint build`](/nx-api/nx/documents/run-many) | +| `--cache-dir` | Set in [`nx.json` under `cacheDirectory`](/reference/nx-json#task-options) | +| `--concurrency` | [`--parallel`](/nx-api/nx/documents/run-many#parallel) | +| `--continue` | [Use `--nx-bail`](/nx-api/nx/documents/run-many#nx-bail) with the inverse value | +| `--cpuprofile` | Use [`NX_PROFILE=profile.json`](/troubleshooting/performance-profiling). | +| `--cwd` | Available when using the [`run-commands` executor](/nx-api/nx/executors/run-commands#cwd) | +| `--deamon` | Use [`NX_DAEMON=false` or set `useDaemonProcess: false`](/concepts/nx-daemon#turning-it-off) in `nx.json` | +| `--dry-run` | N/A. Nx has `--dry-run` for `nx generate` but not for running tasks. | +| `--env-mode` | Nx core does not block any environment variables. There are [React](/recipes/react/use-environment-variables-in-react) and [Angular](/recipes/angular/use-environment-variables-in-angular) build executors that handle environment variables in a customized way. | +| `--filter` | Use [`-p admin-*` or `-p tag:api-*`](/nx-api/nx/documents/run-many#projects). Also see [`nx affected`](/nx-api/nx/documents/affected). | +| `--force` | [`nx reset`](/nx-api/nx/documents/reset) and then run the command again | +| `--framework-inference` | Nx knows if you're using a particular framework if you use an executor for that framework. | +| `--global-deps` | Use [`inputs` in the `nx.json`](/recipes/running-tasks/configure-inputs) or project configuration | +| `--graph` | [Same syntax](/nx-api/nx/documents/run-many#graph) or [`nx graph`](/nx-api/nx/documents/dep-graph) for the entire graph | +| `--heap` | N/A. [`--verbose`](/nx-api/nx/documents/run-many#verbose) for more logging. | +| `--ignore` | Use an [`.nxignore` file](/reference/nxignore) (or `.gitignore`) | +| `--log-order` | Use [`--output-style`](/nx-api/nx/documents/run-many#output-style) | +| `--no-cache` | Use [`--skip-nx-cache`](/nx-api/nx/documents/run-many#skip-nx-cache) | +| `--output-logs` | Use [`--output-style`](/nx-api/nx/documents/run-many#output-style) | +| `--only` | N/A | +| `--parallel` | N/A | +| `--preflight` | N/A | +| `--remote-only` | N/A. Can [ignore the remote cache](/ci/features/remote-cache#skipping-cloud-cache) with `--no-cloud`. | +| `--summarize` | N/A | +| `--token` | Set the [Nx Cloud CI Access Token](/ci/recipes/security/access-tokens#setting-ci-access-tokens) or as an environment variable (`NX_CLOUD_ACCESS_TOKEN`) | +| `--team` | See `--token` for choosing a different Nx Cloud workspace. You can [use `--runner`](/nx-api/nx/documents/run-many#runner) to choose a different runner defined in the `nx.json` file. | +| `--trace` | N/A. [`--verbose`](/nx-api/nx/documents/run-many#verbose) for more logging. | +| `--verbosity` | Use [`--verbose`](/nx-api/nx/documents/run-many#verbose) | +| `turbo gen` | [Use `nx generate`](/nx-api/nx/documents/generate) | +| `turbo login` | No need. [Create an Nx Cloud account](/nx-api/nx/documents/connect-to-nx-cloud) once to set up Nx Cloud. | +| `turbo link` | [Create an Nx Cloud account](/nx-api/nx/documents/connect-to-nx-cloud) |