CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-loopback--build

A comprehensive set of build tools and configurations for LoopBack 4 and TypeScript projects providing CLI commands for compilation, linting, testing, and coverage

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

@loopback/build

@loopback/build is a comprehensive set of build tools and configurations specifically designed for LoopBack 4 and other TypeScript projects. It provides command-line utilities for TypeScript compilation, code linting, formatting, testing, and coverage, along with programmatic APIs for integration into build workflows.

Package Information

  • Package Name: @loopback/build
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install @loopback/build --save-dev

Core Imports

import { 
  tsc,
  prettier,
  mocha,
  nyc,
  clean,
  runCLI, 
  runShell, 
  mergeMochaConfigs, 
  typeScriptPath 
} from "@loopback/build";

For CommonJS:

const { 
  tsc,
  prettier,
  mocha,
  nyc,
  clean,
  runCLI, 
  runShell, 
  mergeMochaConfigs, 
  typeScriptPath 
} = require("@loopback/build");

Basic Usage

{
  "scripts": {
    "build": "lb-tsc",
    "build:watch": "lb-tsc --watch",
    "clean": "lb-clean",
    "lint": "npm run prettier:check && npm run eslint",
    "lint:fix": "npm run prettier:fix && npm run eslint:fix",
    "prettier:cli": "lb-prettier \"**/*.ts\" \"**/*.js\"",
    "prettier:check": "npm run prettier:cli -- -l",
    "prettier:fix": "npm run prettier:cli -- --write",
    "eslint": "lb-eslint --report-unused-disable-directives .",
    "eslint:fix": "npm run eslint -- --fix",
    "pretest": "npm run clean && npm run build",
    "test": "lb-mocha \"dist/__tests__\"",
    "posttest": "npm run lint"
  }
}

Architecture

@loopback/build is built around several key components:

  • CLI Tools: Command-line executables (lb-tsc, lb-eslint, etc.) that wrap popular development tools
  • Programmatic API: Node.js functions for programmatic access to build operations
  • Utility Functions: Helper functions for CLI resolution, configuration loading, and process management
  • Default Configurations: Pre-configured settings for TypeScript, ESLint, Prettier, Mocha, and NYC
  • Console Log Detection: Advanced Mocha integration that detects and fails on unexpected console output

Capabilities

TypeScript Compilation

TypeScript compiler wrapper with support for ttypescript plugins, resource copying, and automatic configuration generation.

function tsc(argv: string[], options?: RunOptions): ChildProcess | string;

TypeScript Compilation

Code Linting

ESLint integration with automatic configuration discovery and LoopBack-specific rules through the lb-eslint CLI command.

Code Linting

Code Formatting

Prettier integration with configuration discovery and file pattern support.

function prettier(argv: string[], options?: RunOptions): ChildProcess | string;

Code Formatting

Test Execution

Mocha test runner with console log detection, configuration merging, and enhanced error reporting.

function mocha(argv: string[], options?: RunOptions): ChildProcess | string;

Test Execution

Code Coverage

NYC code coverage wrapper for generating test coverage reports.

function nyc(argv: string[], options?: RunOptions): ChildProcess | string;

Code Coverage

File Cleanup

Utility for safely removing build artifacts and temporary files.

function clean(argv: string[], options?: RunOptions): string;

File Cleanup

Process Management

Core utilities for running CLI commands and managing child processes.

function runCLI(
  cli: string,
  args: string[],
  options?: RunCLIOptions
): ChildProcess | string;

function runShell(
  command: string,
  args: string[],
  options?: RunShellOptions
): ChildProcess | string;

Process Management

Types

import { ChildProcess } from "child_process";

interface RunOptions {
  dryRun?: boolean;
  cwd?: string;
  resolveFromProjectFirst?: boolean;
}

interface RunCLIOptions extends RunOptions {
  nodeArgs?: string[];
}

interface RunShellOptions extends RunOptions {
  stdio?: string;
  env?: Record<string, string>;
  shell?: boolean;
}

interface MochaConfig {
  timeout?: number;
  require?: string | string[];
  [key: string]: any;
}
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@loopback/build@12.0.x
Publish Source
CLI
Badge
tessl/npm-loopback--build badge