-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(misc): add more content to Nx and ... guides
- Loading branch information
Showing
39 changed files
with
387 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# File Large Next.js Apps Made Faster by Using Nx | ||
|
||
Repo contains: | ||
|
||
- 5 shared buildable packages/libraries with 250 components each | ||
- 5 Next.js applications built out of 20 app-specific libraries. Each app-specific lib has 250 components each. Each library uses the shared components. | ||
|
||
The repo shows how Nx works in a large workspace. It also benchmarks Nx and explains the optimisations Nx uses to be fast. | ||
|
||
**Repository:** [vsavkin/large-monorepo](https://github.com/vsavkin/large-monorepo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Distributed Task Execution at Scale | ||
|
||
Repo contains: | ||
|
||
- 5 shared buildable packages/libraries with 250 components each | ||
- 5 Next.js applications built out of 20 app-specific libraries. Each app-specific lib has 250 components each. Each library uses the shared components. | ||
|
||
The repo shows how Nx distributed task execution can make the CI 16 times faster with a small configuration change. | ||
|
||
**Repository:** [vsavkin/interstellar](https://github.com/vsavkin/interstellar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,90 @@ | ||
# Intro to Nx | ||
# Nx and Angular | ||
|
||
## 10-Minute Nx Overview | ||
Nx is a smart, fast and extensible build system with first class monorepo support and powerful integrations. It has a powerful core and a rich plugin ecosystem. | ||
|
||
<iframe width="560" height="315" src="https://www.youtube.com/embed/cXOkmOy-8dk" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"></iframe> | ||
## Making Things Fast | ||
|
||
## Learn Nx Fundamentals | ||
If you're only interested in improving the performance of your monorepo by using Nx's [affected:\* commands](/using-nx/affected), [computation cache](/using-nx/cache), and [distributed task execution](/using-nx/dte), then you don't need to use any plugins. Everything will work the same way whether your monorepo has React, Vue, Svelte, or even Go, Rust, or Java apps. Nx is technology-agnostic. | ||
|
||
Check out the following guides to get started: | ||
|
||
- [Installing Nx CLI & creating a new Nx Workspace](/{{framework}}/getting-started/nx-setup) | ||
- [Adding Nx to an existing monorepo](/{{framework}}/migration/adding-to-monorepo) | ||
- [Adding Nx to an Angular CLI project](/{{framework}}/migration/migration-angular) | ||
- [Migrating from AngularJS](/{{framework}}/migration/migration-angularjs) | ||
- [Using Nx without plugins](/{{framework}}/getting-started/nx-core) | ||
- [CI Overview](/using-nx/ci-overview) | ||
|
||
It is also a good idea to read the [mental model guide](/using-nx/mental-model) to understand how Nx works. | ||
|
||
## Nx and Angular Plugins | ||
|
||
Nx plugins helps you develop [Angular](/{{framework}}/angular/overview) applications with fully integrated support for | ||
modern tools and libraries like [Jest](/{{framework}}/jest/overview), [Cypress](/{{framework}}/cypress/overview), | ||
[ESLint](/{{framework}}/linter/eslint), Storybook, [NgRx](/angular/guides/misc-ngrx) and more. | ||
|
||
### 10-min Video Overview | ||
|
||
<iframe width="560" height="315" src="https://www.youtube.com/embed/sNz-4PUM0k8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"></iframe> | ||
|
||
Check out the following to get started: | ||
|
||
- [Angular: Interactive Nx Tutorial (with videos)](/angular-tutorial/01-create-application) | ||
- [Free Nx Course on YouTube](https://www.youtube.com/watch?time_continue=49&v=2mYLe9Kp9VM&feature=emb_logo) | ||
|
||
## Nx and Angular CLI | ||
|
||
**If you add Nx to an Angular CLI project, `ng` and `nx` are interchangeable (they invoke the same command). So anywhere you see `"nx build"` or `"nx affected"`, you can also use `"ng build"` or `"ng affected"`.** | ||
|
||
Nx integrates well with the Angular CLI: | ||
|
||
- It decorates the Angular CLI. After adding Nx to your workspace, running `ng` will run the wrapped Angular CLI that goes through Nx. Everything will work the same way but a lot faster. | ||
- It supports all Angular Devkit builders and schematics. | ||
- It supports using `angular.json` to configure projects and their targets. | ||
- Nx Console works with Angular CLI projects. | ||
|
||
This works so well that often folks don't even know they use Nx. | ||
|
||
## Angular CLI, however, has some limitations, and Nx addresses them. | ||
|
||
### angular.json is too long | ||
|
||
Nx allows you to split `angular.json` into multiple configuration files (one for each project). This is a big deal for large workspaces where `angular.json` can be thousands of lines long. | ||
|
||
This is how you do it: | ||
|
||
- Change the version number in `angular.json` to `2` | ||
- Run `nx format` | ||
- Run `nx generate @nrwl/workspace:convert-to-nx-project --all=true` | ||
|
||
Note that even though the configuration is split, everything works the same way. All migrations and schematics that expect a single `angular.json` file, will receive a single file. Nx is smart, so it merges all the files in memory to make those migrations and schematics work. | ||
|
||
### 'ng update' and 'nx migrate' | ||
|
||
If you haven't used Nx before and used the Angular CLI, you probably ran `ng update`. What is the difference? | ||
|
||
`nx migrate` is a much improved version of `ng update`. It runs the same migrations, but allows you to: | ||
|
||
- Rerun the same migration multiple times. | ||
- Reorder migrations. | ||
- Skip migrations. | ||
- Fix migrations that "almost work". | ||
- Commit a partially migrated state. | ||
- Change versions of packages to match org requirements. | ||
|
||
And, in general, it is lot more reliable for non-trivial workspaces. Why? | ||
|
||
`ng update` tries to perform migration in a single go, automatically. This doesn't work for most non-trivial workspaces. | ||
|
||
- `ng update` doesn't separate updating `package.json` from updating the source code of the repo. It all happens in a single go. This often fails for non-trivial workspaces or for organizations that have a custom npm registry, where you might want to use a different version of a package. | ||
- `ng update` relies on `peerDependencies` to figure out what needs to be updated. Many third-party plugin don't have `peerDependencies` set correctly. | ||
- When using `ng update` it is difficult to execute one migration at a time. Sometimes you want to patch things up after executing a migration. | ||
- When using `ng update` it's not possible to fix almost-working migrations. We do our best but sometimes we don't account for the specifics of a particular workspace. | ||
- When using `ng update` it's not possible to commit a partially-migrated repo. Migration can take days for a large repo. | ||
- When using `ng update` it's not possible to rerun some of the migrations multiple times. This is required because you can rebase the branch multiple times while migrating. | ||
|
||
The Nx core team have gained a lot of experience migrating large workspaces over the last 5 years, and `nx migrate` has been consistently a lot more reliable and easier to use. It has also been a lot easier to implement migrations that work with `nx migrate` comparing to `ng update`. As a result, folks building React and Node applications with Nx have had better experience migrating because Angular folks use `ng update` out of habit, instead of using the command that works better. | ||
|
||
**Starting with Nx 11, you can migrate workspaces only using `nx migrate`**. To reiterate: `nx migrate` runs the migrations written by the Angular CLI team the same way `ng update` runs them. So everything should still work. You just get more control over how it works. | ||
|
||
If you still want to run `ng update`, you can do it as follows: `FORCE_NG_UPDATE=true nx update mypackage`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
# Nx and React | ||
|
||
## 10-Minute Nx Overview | ||
Nx is a smart, fast and extensible build system with first class monorepo support and powerful integrations. It has a powerful core and a rich plugin ecosystem. | ||
|
||
## Making Things Fast | ||
|
||
If you're only interested in improving the performance of your monorepo by using Nx's [affected:\* commands](/using-nx/affected), [computation cache](/using-nx/cache), and [distributed task execution](/using-nx/dte), then you don't need to use any plugins. Everything will work the same way whether your monorepo has React, Vue, Svelte, or even Go, Rust, or Java apps. Nx is technology-agnostic. | ||
|
||
Check out the following guides to get started: | ||
|
||
- [Installing Nx CLI & creating a new Nx Workspace](/{{framework}}/getting-started/nx-setup) | ||
- [Adding Nx to an existing monorepo](/{{framework}}/migration/adding-to-monorepo) | ||
- [Migrating from CRA](/{{framework}}/migration/migration-cra) | ||
- [Using Nx without plugins](/{{framework}}/getting-started/nx-core) | ||
- [CI Overview](/using-nx/ci-overview) | ||
|
||
It is also a good idea to read the [mental model guide](/using-nx/mental-model) to understand how Nx works. | ||
|
||
## Nx and React Plugins | ||
|
||
Nx plugins help you develop [React](/{{framework}}/react/overview) applications with fully integrated support for modern tools | ||
and libraries like [Jest](/{{framework}}/jest/overview), [Cypress](/{{framework}}/cypress/overview), | ||
Storybook, [ESLint](/{{framework}}/linter/eslint), and more. Nx also supports React | ||
frameworks like [Gatsby](/{{version}}/react/gatsby/overview), [Next.js](/{{version}}/react/guides/nextjs), Remix, and has great support for React Native. | ||
|
||
### 10-min Video Overview | ||
|
||
<iframe width="560" height="315" src="https://www.youtube.com/embed/sNz-4PUM0k8" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"></iframe> | ||
|
||
## Learn | ||
Check out the following to get started: | ||
|
||
- [React: Interactive Nx Tutorial (with videos)](/react-tutorial/01-create-application) | ||
- [Free Nx Course on Egghead: Scale React Development with Nx](https://egghead.io/playlists/scale-react-development-with-nx-4038) | ||
- [45-Minute Walkthrough](https://www.youtube.com/watch?v=jCf92IyR-GE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9b947a5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: