feat(config): add smartconfig metadata and update TypeScript build configuration docs

This commit is contained in:
2026-03-24 18:13:56 +00:00
parent cfe2eafe89
commit 724e5bf7ec
10 changed files with 1196 additions and 2042 deletions

View File

@@ -7,11 +7,13 @@
2. **TsConfig** - TypeScript configuration management (tsconfig.json handling)
3. **TsPublishConfig** - TsPublish configuration (tspublish.json handling)
4. **TsUnpacker** - Output directory flattening
5. **FsHelpers** - Filesystem utilities (static methods)
6. **TsBuildCli** - CLI command handler
5. **TsPathRewriter** - Cross-module import path rewriting in compiled output
6. **FsHelpers** - Filesystem utilities (static methods)
7. **TsBuildLogger** - Centralized structured console output (4-level hierarchy)
8. **TsBuildCli** - CLI command handler
### CLI Commands (5)
1. **tsbuild** (default) - Compiles ./ts/**/*.ts ./dist_ts/
1. **tsbuild** (default) - Compiles ./ts/**/*.ts -> ./dist_ts/
2. **tsbuild custom <dir1> <dir2>** - Custom directory compilation
3. **tsbuild tsfolders** - Auto-discover ts_* folders, compile in order
4. **tsbuild emitcheck <pattern>** - Validate emit without output
@@ -32,6 +34,7 @@
ts/
index.ts # Main entry, re-exports all modules
plugins.ts # Dependency imports only
00_commitinfo_data.ts # Commit info data
mod_fs/
index.ts # exports
@@ -46,9 +49,17 @@ ts/
index.ts # exports
classes.tsunpacker.ts # TsUnpacker - output flattening
mod_pathrewrite/
index.ts # exports
classes.tspathrewriter.ts # TsPathRewriter - import path rewriting
mod_logger/
index.ts # exports
classes.logger.ts # TsBuildLogger - structured console output
mod_compiler/
index.ts # exports
classes.tscompiler.ts # TsCompiler + legacy compatibility functions
classes.tscompiler.ts # TsCompiler - main compilation engine
mod_cli/
index.ts # exports
@@ -62,6 +73,7 @@ ts/
- Type checking with `checkTypes()`, `checkEmit()`
- Configuration via TsConfig
- Automatic unpacking via TsUnpacker
- Import path rewriting via TsPathRewriter (in compileGlob)
**TsConfig** (`mod_config/classes.tsconfig.ts`)
- Load and parse tsconfig.json
@@ -78,8 +90,18 @@ ts/
- Flatten output directories
- Configurable via TsPublishConfig
**TsPathRewriter** (`mod_pathrewrite/classes.tspathrewriter.ts`)
- Auto-detect ts_* folders in project
- Rewrite ES module imports, dynamic imports, and require() calls
- Transforms `../ts_*` references to `../dist_ts_*` in compiled output
**TsBuildLogger** (`mod_logger/classes.logger.ts`)
- 4-level visual hierarchy: HEADER, STEP, DETAIL, SUCCESS/ERROR/WARN
- ANSI color output
- Static methods (no instantiation needed)
**FsHelpers** (`mod_fs/classes.fshelpers.ts`)
- `listFilesWithGlob()` - Glob pattern file listing
- `listFilesWithGlob()` - Glob pattern file listing via smartfs
- `extractSourceFolder()` - Pattern parsing
- File/directory existence checks
- Directory operations
@@ -103,8 +125,8 @@ Cannot be overridden by tsconfig.json alone:
- `inlineSourceMap: true` - Debugging
### Path Transformation
- Automatic: `./ts_interfaces` `./dist_ts_interfaces`
- In tsconfig paths: `./ts_*` `./dist_ts_*` (first array element only)
- Automatic: `./ts_interfaces` -> `./dist_ts_interfaces`
- In tsconfig paths: `./ts_*` -> `./dist_ts_*` (first array element only)
## Default Compiler Options
- Module: NodeNext (ESM with CommonJS fallback)
@@ -137,14 +159,16 @@ interface ICompileResult {
```
## Dependencies Used
- @git.zone/tspublish@^1.10.3 - Module ordering
- @push.rocks/smartcli@^4.0.19 - CLI framework
- @git.zone/tspublish@^1.11.3 - Module ordering
- @push.rocks/early@^4.0.4 - Early initialization
- @push.rocks/smartcli@^4.0.20 - CLI framework
- @push.rocks/smartdelay@^3.0.5 - Delay utilities
- @push.rocks/smartfile@^13.1.2 - File content handling
- @push.rocks/smartfs@^1.2.0 - Filesystem operations
- @push.rocks/smartfs@^1.5.0 - Filesystem operations
- @push.rocks/smartlog@^3.2.1 - Logging
- @push.rocks/smartpath@^6.0.0 - Path transformation utilities
- @push.rocks/smartpromise@^4.2.3 - Promise utilities
- @push.rocks/smartdelay@^3.0.5 - Delay utilities
- typescript@5.9.3 - TypeScript compiler
- typescript@^6.0.2 - TypeScript compiler
### smartfs Usage
- File listing: `smartfs.directory(path).recursive().filter(pattern).list()`
@@ -152,29 +176,32 @@ interface ICompileResult {
- Directory existence: `smartfs.directory(path).exists()`
- FsHelpers wraps smartfs for glob pattern support
## Compilation Pipeline (compileGlob)
1. **Phase 1: Resolve & Clean** - Resolve glob patterns, list files, clear all output dirs
2. **Phase 2: Compile** - Compile each task sequentially with error tracking
3. **Phase 3: Unpack** - Flatten nested output directories for successful compilations
4. **Phase 4: Path Rewrite** - Rewrite cross-module import paths in output dirs
## Unpack Feature
When TypeScript compiles files that import from sibling directories, it creates nested output:
```
dist_ts_core/
ts_core/ nested output
ts_shared/ pulled-in dependency
ts_core/ <- nested output
ts_shared/ <- pulled-in dependency
```
The unpack feature automatically flattens this to:
```
dist_ts_core/
index.js flat
index.js <- flat
```
### Configuration
- Reads `tspublish.json` from source folder
- `unpack: true` (default if not present) flatten output
- `unpack: false` skip unpacking
### Implementation
- `TsUnpacker` class in `mod_unpack/classes.tsunpacker.ts`
- Called automatically after each successful compilation in `TsCompiler.compileGlob()`
- `unpack: true` (default if not present) -> flatten output
- `unpack: false` -> skip unpacking
## Special Behaviors
@@ -206,10 +233,4 @@ Two-phase check:
- Protected options ensure integrity
- Pre-emit checks before emit phase
- CLI exit code handling (0=success, 1=error)
## Recent Changes
- 3.1.4+ - Major restructuring with mod_* modules
- Full OO architecture with TsCompiler, TsConfig, TsPublishConfig, TsUnpacker, TsBuildCli, FsHelpers
- Backward compatibility maintained for legacy functions
- Automatic "unpack" feature for nested output directories
- Migrated filesystem operations from smartfile to smartfs
- Event loop yield after emit for XFS filesystem reliability