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

typescript-compilation.mddocs/

TypeScript Compilation

TypeScript compiler wrapper providing enhanced functionality for LoopBack 4 projects including ttypescript support, resource copying, and automatic configuration generation.

Capabilities

lb-tsc / lb-ttsc Command

Compiles TypeScript files with automatic configuration discovery and enhanced features.

/**
 * TypeScript compiler function with enhanced features
 * @param argv - Command line arguments including options
 * @param options - Execution options for dry run and process control
 * @returns ChildProcess when executed, string when dry run
 */
function tsc(argv: string[], options?: RunOptions): ChildProcess | string;

CLI Usage:

# Standard TypeScript compilation
lb-tsc

# Watch mode
lb-tsc --watch

# Custom target and output directory
lb-tsc --target es2017 --outDir dist

# Copy non-TypeScript resources
lb-tsc --copy-resources

# Use ttypescript for plugins
lb-ttsc
# or
lb-tsc --use-ttypescript

# Custom project file
lb-tsc -p tsconfig.build.json

Programmatic Usage:

import { tsc } from "@loopback/build";

// Compile with default settings
const child = tsc(process.argv);

// Dry run to see command
const command = tsc(["--watch"], { dryRun: true });
console.log(command); // "node .../tsc --watch"

// Custom working directory
tsc(["--outDir", "build"], { cwd: "/path/to/project" });

TypeScript Configuration Discovery

Automatically discovers and creates TypeScript configuration files.

Configuration Search Order:

  1. tsconfig.build.json in project root
  2. tsconfig.json in project root
  3. Auto-generated tsconfig.json extending @loopback/build/config/tsconfig.common.json

Auto-generated Configuration:

{
  "extends": "@loopback/build/config/tsconfig.common.json",
  "compilerOptions": {
    "outDir": "dist",
    "rootDir": "src"
  },
  "include": ["src"]
}

ttypescript Support

Optional integration with ttypescript for TypeScript plugin support.

// lb-ttsc automatically uses ttypescript if available
// lb-tsc --use-ttypescript flag enables ttypescript

Requirements:

  • ttypescript package must be installed
  • Fails gracefully if ttypescript is not available

Resource Copying

Copies non-TypeScript files from source to output directory.

// --copy-resources flag enables file copying
// Copies all non-.ts files from src/ and test/ directories
// Preserves relative directory structure

Usage Examples:

# Copy resources during compilation
lb-tsc --copy-resources

# Copy resources with custom configuration
lb-tsc --copy-resources --outDir build --rootDir src

Copied File Patterns:

  • All files in src/ directory (excluding .ts files)
  • All files in test/ directory (excluding .ts files)
  • Preserves directory structure relative to rootDir

Composite Project Support

Supports TypeScript composite projects with tsc -b build mode.

// Automatically detects composite projects via tsconfig references
// Uses 'tsc -b' for composite project builds
// Filters invalid arguments for build mode

Usage:

// tsconfig.json with references
{
  "references": [
    { "path": "./packages/core" },
    { "path": "./packages/utils" }
  ]
}

Advanced Options

Additional compiler options specific to @loopback/build.

interface CompilerOptions {
  "--copy-resources": boolean;  // Copy non-TS files to outDir
  "--use-ttypescript": boolean; // Use ttypescript instead of tsc
  "--target": string;           // TypeScript compilation target
  "--outDir": string;           // Output directory
  "-p" | "--project": string;   // Project file path
}

Option Processing:

  • Custom options are removed before passing to TypeScript compiler
  • Target and output directory are extracted and handled separately
  • Project file path is resolved relative to current working directory

Default TypeScript Configuration

Base configuration provided by @loopback/build.

// config/tsconfig.common.json contents:
interface TypeScriptConfig {
  compilerOptions: {
    emitDecoratorMetadata: true;
    experimentalDecorators: true;
    resolveJsonModule: true;
    skipLibCheck: true;
    strict: true;
    strictPropertyInitialization: false;
    useUnknownInCatchVariables: false;
    incremental: true;
    lib: ["es2020"];
    module: "commonjs";
    esModuleInterop: true;
    moduleResolution: "node";
    target: "es2018";
    sourceMap: true;
    declaration: true;
    importHelpers: true;
  };
}

docs

code-coverage.md

code-formatting.md

code-linting.md

file-cleanup.md

index.md

process-management.md

test-execution.md

typescript-compilation.md

tile.json