How sap/ui5-builder works
Project Type and Purpose
• This is a Node.js library (part of the UI5 Tooling) that provides build modules, tasks, and processors for UI5 applications and libraries.
• It exposes an API (@ui5/builder) used by the UI5 CLI or programmatic consumers to orchestrate build pipelines for UI5 artifacts.
Top-Level Architectural Components
• Entrypoint / API Layer: The module consumers (UI5 CLI or other tools) import @ui5/builder and invoke its build function.
• Core Engine: Orchestrates the build: loads configuration (ui5.yaml), discovers and invokes tasks.
• Task Repository: Registry of high-level build tasks (e.g. “buildThemes”, “generateLibraryPreload”).
• Tasks (lib/tasks): Each implements one build step by invoking one or more processors.
• Processors (lib/processors): Fine-grained data transformers (e.g. manifest enhancer, module bundler, minifier, jsdoc generator).
• Library Build Tools (lbt) (lib/lbt): Core algorithms and helpers for analyzing modules, building dependency graphs, resolving and writing bundles.
• Utilities (lib/utils): File‐system helpers, AST utilities, tokenizers, module‐name parsers, etc.
• External Services:
• Node.js File System (read/write project sources and outputs)
• JSDoc engine (via jsdoc plugins)
• Terser or other minifier backends
Relationship and Data Flow
1. Consumer (UI5 CLI) → invokes → Core Engine
2. Core Engine → reads → project config (ui5.yaml, package.json)
3. Core Engine → queries → Task Repository for applicable tasks
4. Task → for each → calls one or more → Processors
5. Processor → uses → lbt.analyzer (builds AST, extracts module metadata)
6. Processor → uses → lbt.graph (builds dependency graph, sorts modules)
7. Processor → uses → lbt.bundle (resolves bundle definitions, writes bundle files)
8. Processor → may invoke → minifier, jsdoc generator, theme builder, string replacer, etc.
9. Processed resources → written back via → Utilities.fs to the output folder.
Architectural Patterns and Principles
• Plugin / Registry Pattern: Tasks and processors register themselves in the Task Repository.
• Pipeline / Chain of Responsibility: Build is a sequence of tasks; each task is a chain of processors.
• Modular Separation:
• Tasks only orchestrate;
• Processors only transform;
• lbt modules only analyze/bundle;
• Utils only support IO and parsing.
• Single Responsibility: Each file/module has a focused role.
Technology Stack and Key Libraries
• Node.js (JavaScript/ES modules)
• @ui5/builder API (this repo)
• JSDoc (via lib/processors/jsdoc)
• Terser (for minification)
• YAML parser (for ui5.yaml)
• GitHub Actions / Azure Pipelines (CI/CD)