Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why nrwl/nx is better that angular@6 vanilia?

Biggest advantage og nrwl/nx was implementing multiple workspaces in one project. Now angular 6 supperts it as well. What are other adventages of nx over angular@6 ?

like image 892
piernik Avatar asked May 21 '18 07:05

piernik


People also ask

Why should I use NX Angular?

Nx plugins helps you develop Angular applications with fully integrated support for modern tools and libraries like Jest, Cypress, ESLint, Storybook, NgRx and more.

What is the purpose of NX?

Nx analyzes your workspace to improve performance and developer experience. Nx distributes any command across multiple machines without any configuration. Nx never rebuilds or tests the same code twice. Nx simplifies extracting and refactoring shared libraries.

What is NX workspace in Angular?

Nx Workspace is a tool suite designed to architect, build and manage monorepos at any scale. It has out-of-the-box support for multiple frontend frameworks like Angular and React as well as backend technologies including Nest, Next, and Express.

Is NX only for JavaScript?

Nx is a general-purpose build system and a general-purpose CLI. It works with JavaScript, TypeScript, Java, C#, Go, etc.. The core plugins Nx comes with do work best with JavaScript or TypeScript. You can build/test/lint/serve your applications and libraries the same way whether you use JavaScript and TypeScript.

Is nrwl NX an angular CLI extension?

Angular CLI 1.x wasn’t a great fit for Nx. We talked to the Angular CLI team, and they shared the design docs for what became Angular CLI 6. It was clear that most of what we needed to make Nx excellent would be available in future versions of the Angular CLI. So we decided to invest the effort to make Nrwl Nx an extension to Angular CLI 1.x.

Can I use NX with angular?

Nx also supports optional free cloud support with Nx Cloud, as well as GitHub integration. Regardless of how you use Nx (with Angular CLI or standalone), you can always use the Angular Devkit. You can generate code using schematics and invoke builders. But there is an alternative: you can use Nx Devkit.

What is the difference between ng build and NX build?

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.

What is “modern angular?

“Modern Angular” also means working together with other frameworks. Most large companies use multiple frameworks to build their applications. One org can use Angular, another one can use React, and this is OK. Nx provides the same dev experience for many frameworks including Angular and React.


1 Answers

nx is amazing, i'm using it because we have 5 angular applications in a big project,and i think that nrwl/nx is made for complex enterprise applications, so if you have a big project composed of many frontend applications it will be useful, but even for a single app that will give you many advantages, here is some benefits of nx :

  • you will have a monorepo for all your apps that share the same package.json, so you have to manage packages once for all your apps
  • more consistency and productivity
  • you can create libs that can be shared between your apps,it will save your time, and the team say that it's better to put all your logic code inside libs even if they are not shared between apps
  • more options for code generation if we compare it with the standard cli
  • you will have a great routing and state management (ngrx) implementation (implemented the right one)
  • build time improvement: with nx you will avoid re-executing unnecessary builds, so if you make some changes on a lib, nx will make sure that only apps that depend on it will build.
  • the future of nx is to have a powerful mono repo tool with a great build system (a version of Bazel for nx) and may your project ready for CI

with one command you can build or test apps affected by your changes

yarn affected:build --all --prod
yarn affected:test --all --prod
  • Now it's possible to generate many types of frontend applications ANGULAR, REACT // for generateing a react app ng add @nrwl/react # Add React capabilities to your workspace ng g @nrwl/react:application reactAppName

    // for generating an angular app
    ng add @nrwl/angular
    ng g @nrwl/angular:application angularAppName
    
  • Generate backend applications for your frontend app like Nest and create shared libs between frontend and backend apps in a flexible way

    ng add @nrwl/nest
    ng g @nrwl/nest:app api --frontendProject=YOU_FRONTEND_PROJECT // link the generate nest app to a specific frontend app 
    
like image 173
Fateh Mohamed Avatar answered Oct 15 '22 05:10

Fateh Mohamed