CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-angular-devkit--build-ng-packagr

Angular Build Architect builder for ng-packagr library packaging (deprecated)

89

1.00x
Overview
Eval results
Files

task.mdevals/scenario-8/

Angular Library Build Orchestrator

Build a library build orchestration system that manages the compilation and packaging of Angular libraries using the @angular-devkit/build-ng-packagr builder.

Task

Create a build orchestrator that:

  1. Configures and executes library builds through the ng-packagr builder
  2. Manages build caching with environment-aware strategies
  3. Handles both one-shot builds and watch mode
  4. Provides error handling and build status reporting

Your implementation should handle the complete build lifecycle from configuration to execution.

Capabilities

Build Execution

Execute library builds with proper configuration and mode support.

  • When executing a build with valid project path, the builder completes successfully and returns success status @test
  • When project configuration file does not exist, the build fails with appropriate error message @test
  • When watch mode is enabled, the builder continues running and rebuilds on file changes @test

Cache Management

Manage build caching with environment-aware strategies.

  • When cache is enabled for 'local' environment and not in CI, caching is active @test
  • When cache is enabled for 'ci' environment and in CI, caching is active @test
  • When cache directory contains old version data, stale caches are purged before build @test

Configuration Handling

Support flexible build configuration options.

  • When tsConfig option is provided, the builder uses the specified TypeScript configuration @test
  • When poll option is provided with a number, the polling interval is passed to ng-packagr @test

Implementation

@generates

API

import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
import { Observable } from 'rxjs';

/**
 * Options for configuring the library build
 */
export interface BuildOptions {
  /** Path to ng-package.json configuration file */
  project: string;
  /** Optional path to TypeScript configuration file */
  tsConfig?: string;
  /** Enable watch mode for continuous rebuilds */
  watch?: boolean;
  /** Polling interval in milliseconds for file watching */
  poll?: number;
}

/**
 * Cache configuration for the build process
 */
export interface CacheConfig {
  /** Whether caching is enabled */
  enabled: boolean;
  /** Cache environment strategy: 'local', 'ci', or 'all' */
  environment: 'local' | 'ci' | 'all';
  /** Path to the cache directory */
  directory: string;
}

/**
 * Executes the library build process with the given options
 *
 * @param options - Build configuration options
 * @param context - Builder context with workspace information
 * @returns Observable that emits build results
 */
export function executeBuild(
  options: BuildOptions,
  context: BuilderContext
): Observable<BuilderOutput>;

/**
 * Configures caching strategy based on environment
 *
 * @param cacheMetadata - Cache configuration from project metadata
 * @param isCI - Whether running in CI environment
 * @returns Resolved cache configuration
 */
export function configureCaching(
  cacheMetadata: { enabled?: boolean; environment?: 'local' | 'ci' | 'all'; path?: string },
  isCI: boolean
): CacheConfig;

/**
 * Purges stale build caches from previous versions
 *
 * @param cacheDirectory - Root cache directory path
 * @param currentVersion - Current Angular version
 * @returns Promise that resolves when cleanup is complete
 */
export function purgeStaleCache(
  cacheDirectory: string,
  currentVersion: string
): Promise<void>;

Dependencies { .dependencies }

@angular-devkit/build-ng-packagr { .dependency }

Provides the ng-packagr builder for compiling and packaging Angular libraries

@satisfied-by

@angular-devkit/architect { .dependency }

Provides builder context and output types for Angular Architect system

@satisfied-by

rxjs { .dependency }

Provides Observable support for reactive build process management

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-angular-devkit--build-ng-packagr

tile.json