CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nestjs--cli

Command-line interface tool for initializing, developing, and maintaining NestJS applications

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

application-building.mddocs/

Application Building

Build NestJS applications for production with support for multiple build systems, watch mode, and advanced compilation options. The CLI supports TypeScript compiler, Webpack, and SWC for different performance and feature requirements.

Capabilities

Build Command

Compiles your NestJS application with comprehensive configuration options and multiple builder support.

# Build applications
nest build [apps...] [options]

# Options:
-c, --config [path]                 # Path to nest-cli configuration file
-p, --path [path]                   # Path to tsconfig file
-w, --watch                        # Run in watch mode (live-reload)
-b, --builder [name]               # Builder to be used (tsc, webpack, swc)
--watchAssets                      # Watch non-ts (e.g., .graphql) files mode
--webpack                          # Use webpack for compilation (deprecated, use --builder)
--type-check                       # Enable type checking (when SWC is used)
--webpackPath [path]               # Path to webpack configuration
--tsc                             # Use typescript compiler for compilation
--preserveWatchOutput             # Use "preserveWatchOutput" option when using tsc watch mode
--all                             # Build all projects in a monorepo

Usage Examples:

# Basic build
nest build

# Build specific app in monorepo
nest build api-gateway

# Build with watch mode
nest build --watch

# Build using specific builder
nest build --builder webpack
nest build --builder swc
nest build --builder tsc

# Build with asset watching
nest build --watch --watchAssets

# Build all projects in monorepo
nest build --all

# Build with custom config file
nest build --config nest-cli.production.json

# Build with custom TypeScript config
nest build --path tsconfig.production.json

Build Systems

TypeScript Compiler (tsc)

The default TypeScript compiler provides standard compilation with full type checking.

# Use TypeScript compiler explicitly
nest build --builder tsc
nest build --tsc

# With watch mode and preserved output
nest build --tsc --watch --preserveWatchOutput

Features:

  • Full type checking
  • Standard TypeScript compilation
  • Source map generation
  • Declaration file generation
  • Incremental compilation support

Webpack

Advanced bundling and optimization with hot module replacement support for development.

# Use Webpack builder
nest build --builder webpack

# With custom webpack config
nest build --builder webpack --webpackPath webpack.config.js

# Watch mode with Webpack
nest build --builder webpack --watch

Features:

  • Module bundling and optimization
  • Hot module replacement (HMR)
  • Advanced code splitting
  • Asset optimization
  • Development server integration

SWC

High-performance Rust-based compiler for faster builds with optional type checking.

# Use SWC builder
nest build --builder swc

# SWC with type checking enabled
nest build --builder swc --type-check

# SWC in watch mode
nest build --builder swc --watch

Features:

  • Extremely fast compilation
  • TypeScript and JavaScript support
  • Optional type checking
  • Modern JavaScript output
  • Requires @swc/cli and @swc/core dependencies

Watch Mode

Enable automatic rebuilding when files change during development.

# Basic watch mode
nest build --watch

# Watch mode with asset monitoring
nest build --watch --watchAssets

# Watch mode with preserved output (tsc only)
nest build --watch --preserveWatchOutput

Asset Watching

Monitor and rebuild when non-TypeScript files change:

# Watch for changes in .graphql, .json, .proto files
nest build --watch --watchAssets

Supported asset types:

  • GraphQL schema files (.graphql, .gql)
  • JSON configuration files
  • Protocol buffer definitions (.proto)
  • Template files
  • Static assets

Monorepo Support

Build Specific Apps

# Build individual applications
nest build api-gateway
nest build user-service
nest build notification-service

# Build multiple specific apps
nest build api-gateway user-service

Build All Projects

# Build entire monorepo
nest build --all

Configuration Files

nest-cli.json

Project-level build configuration:

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "builder": "webpack",
    "typeCheck": true,
    "assets": ["**/*.proto", "**/*.graphql"],
    "watchAssets": true
  }
}

tsconfig.json Integration

The build command respects TypeScript configuration:

# Use custom tsconfig file
nest build --path tsconfig.production.json

Build Output

Default Output Structure

dist/
├── main.js
├── main.js.map
└── [other compiled files]

Monorepo Output Structure

dist/
├── apps/
│   ├── api-gateway/
│   └── user-service/
└── libs/
    ├── shared/
    └── common/

Builder Selection

The CLI automatically selects the appropriate builder based on:

  1. Explicit --builder flag
  2. nest-cli.json configuration
  3. Available dependencies
  4. Project type and structure

Builder Priority

# Explicit builder flag (highest priority)
nest build --builder swc

# nest-cli.json compilerOptions.builder
# Available dependencies (webpack, swc, tsc)
# Default fallback to tsc

Error Handling

Invalid Builder

# Invalid builder name
nest build --builder invalid
# Error: Invalid builder option: invalid. Available builders: tsc, webpack, swc

Missing Dependencies

When using SWC or Webpack without required dependencies, the CLI provides clear installation instructions.

Performance Optimization

SWC for Speed

# Fastest builds
nest build --builder swc

# Fast builds with type safety
nest build --builder swc --type-check

Webpack for Features

# Advanced optimization and bundling
nest build --builder webpack

# Development with HMR
nest build --builder webpack --watch

TypeScript for Compatibility

# Full TypeScript features and compatibility
nest build --builder tsc

# Incremental builds
nest build --builder tsc --watch

docs

application-building.md

code-generation.md

development-server.md

index.md

library-integration.md

project-creation.md

project-information.md

tile.json