Advertisement

Accelerate Development with NX Build System

Software Engineer at Tiki Corporation
Mar. 30, 2023
Advertisement

More Related Content

Advertisement

Accelerate Development with NX Build System

  1. Accelerate Development with NX Build System Present by Thien Ly March 29, 2023
  2. Table of content * Intro to Nx - Concept of Nx - Pros and cons - Compare Nx to other alternatives * Demo - How to config and use Nx in monorepo - Inherit the caching benefits of Nx - Write and apply a Nx task executor (ft. keystone-6 CLI)
  3. Introduction to NX build system
  4. Introduction to NX build system Nx is a smart, fast and extensible build system with first class monorepo support and powerful integrations. Goals: - Speed up your existing workflow with minimum effort. - Provide a first-rate developer experience (DX) no matter the size of the repo.
  5. Main concepts
  6. Main concepts > Nx is like the VSCode of build tools. The core of Nx enables project and task graph creation and analysis, orchestration and execution of tasks, computation caching, and code generation. Nx plugins extend this functionality and are built on top of the underlying Nx Devkit https://nx.dev/plugin-features/create-your-own-plugin#create-your-own-plugin
  7. Main concepts - Based on the concept of a monorepo which includes many projects - Incremental builds - Ability to manage dependencies (and workspace visualizations) - Reducing the need for duplicative code (especially in setup) - Provide tools(aka NX plugins) to help enforce best practices - Generators: scaffolding source, updating your configuration files - Executors: perform actions on dev’s code; can include building, linting, testing, serving…
  8. Pros and cons
  9. Pros of NX ● Improved Productivity ● Scalability ● Consistency ● Customization: custom plugins, generators, and executors
  10. Cons of NX ● Steep Learning Curve ● Higher Overhead: The added complexity of NX Build System can result in a higher overhead, requiring more time and resources to set up and maintain compared to simpler build systems.
  11. Comparison
  12. Comparison: Nx vs alternatives 1. Yarn workspaces, Lerna Nx and Yarn workspaces are complementary, so it makes sense to use both in some situations Therefore, they are also complementary. - YW main features: linking dependencies, unifize modules,... - Lerna main features: bootstrapping and publishing library with npm registry, npm version tooling,..
  13. Comparison: Nx vs Turborepo 2. Nx Vs Turborepo (according to the article https://nx.dev/more-concepts/turbo- and-nx) Same features: - Incremental Adoption - Project graph visualization - Detecting affected projects/packages - Local task coordination - Local computation caching - Distributed computation caching
  14. Comparison: Nx vs Turborepo Not available on Turborepo: - Distributed task execution - Editor support - Separate configurations - Transparency terminal output - Customizable workflow plugins - Nx has bigger community
  15. Comparison: Nx vs Turborepo Performance: Nx is better. See: - https://github.com/vsavkin/large-monorepo/#benchmarking-nx-turbo-and-lerna - https://nx.dev/more-concepts/turbo-and-nx#tech-and-performance Nx uses NodeJS with C++ modules and tree-diffing algo (like React.js) to restrict almost all unnecessary IO tasks. Turborepo uses Golang. All the caches will blow up on every update if not match cache hashes.
  16. Demo
  17. Demonstrations ● Setup a Nx Package-based Repository ● Setup caching and and build separation ● Task executor with keystone CLI
  18. Gracias ♡ ~ ((Q&&A)||SIGTERM)

Editor's Notes

  1. these projects could include the main application, libraries, and any other related projects.
  2. Improved Productivity: The modular architecture of NX Build System allows for faster and more efficient development, making it easier to build and maintain large projects. Scalability: With support for monorepos, NX Build System can handle large codebases with multiple projects, making it easier to manage dependencies and share code between projects. Consistency: By providing a consistent workflow and set of tools, NX Build System can help enforce best practices and ensure that all code is written and structured consistently. Customization: NX Build System can be easily customized using plugins, generators, and custom schematics, allowing developers to tailor the build process to their specific needs.
  3. Steep Learning Curve: Due to its complexity, NX Build System can have a steep learning curve, especially for developers who are new to monorepo architectures or the Angular framework. Higher Overhead chi phi cao: The added complexity of NX Build System can result in a higher overhead, requiring more time and resources to set up and maintain compared to simpler build systems.
Advertisement