2.3 KiB
2.3 KiB
tswatch Project Hints
Core Architecture
- tswatch is a TypeScript file watcher with multiple operation modes
- Main class
TsWatchorchestrates different watch modes Watcherclass handles individual file watching and command execution
Available Watch Modes
- npm/node (default): Runs
npm teston changes - test: Runs
npm run test2on changes - element: Web component development with dev server on port 3002
- service: Runs
npm run startTsfor service projects - website: Full website mode with bundling and asset processing
- echo: Test mode that runs
npm -v(for testing)
Key Implementation Details
- Uses
@push.rocks/smartwatch(v5.x) for file watching - class isSmartwatch - Uses
@push.rocks/smartfs(v1.x) for directory operations - usesSmartFswithSmartFsProviderNode - Uses
@git.zone/tsbundlefor bundling with esbuild - Uses
@api.global/typedserverfor development server in element mode - Element/website modes watch multiple
ts*/directories - All modes support both command execution and function callbacks
CLI Entry Points
cli.js-> Main CLI entry pointts/tswatch.cli.ts-> CLI implementation with smartcli- Default command triggers npm mode
Project Structure Expectations
ts/- Backend TypeScript filests_web/- Frontend TypeScript files (element/website modes)html/- HTML templates (element/website modes)assets/- Static assets (website mode only)dist_watch/- Output for element modedist_serve/- Output for website mode
Development Server Details
- Port: 3002
- Features: CORS, gzip compression, live reload injection
- Only available in element mode via
typedserverproperty
Common Issues to Watch For
- The test mode runs
test2script, nottest - Website mode restarts the entire server process on backend changes
- Element mode rebuilds and reloads on any ts* folder change
Migration Notes (v2.2.x)
- Replaced
@push.rocks/smartchokwith@push.rocks/smartwatch(v5.x) - Replaced
@push.rocks/smartfilewith@push.rocks/smartfsfor directory listing - Class names:
Smartwatchfor file watching,SmartFs+SmartFsProviderNodefor filesystem ops - Directory paths are converted to glob patterns (
/path/to/dir/→/path/to/dir/**/*) for smartwatch compatibility