Files
tswatch/readme.hints.md
Juergen Kunz ecd76bc8aa update readme
2025-07-10 14:33:10 +00:00

1.8 KiB

tswatch Project Hints

Core Architecture

  • tswatch is a TypeScript file watcher with multiple operation modes
  • Main class TsWatch orchestrates different watch modes
  • Watcher class handles individual file watching and command execution

Available Watch Modes

  1. npm/node (default): Runs npm test on changes
  2. test: Runs npm run test2 on changes
  3. element: Web component development with dev server on port 3002
  4. service: Runs npm run startTs for service projects
  5. website: Full website mode with bundling and asset processing
  6. echo: Test mode that runs npm -v (for testing)

Key Implementation Details

  • Uses @push.rocks/smartchok for file watching
  • Uses @git.zone/tsbundle for bundling with esbuild
  • Uses @api.global/typedserver for 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 point
  • ts/tswatch.cli.ts -> CLI implementation with smartcli
  • Default command triggers npm mode

Project Structure Expectations

  • ts/ - Backend TypeScript files
  • ts_web/ - Frontend TypeScript files (element/website modes)
  • html/ - HTML templates (element/website modes)
  • assets/ - Static assets (website mode only)
  • dist_watch/ - Output for element mode
  • dist_serve/ - Output for website mode

Development Server Details

  • Port: 3002
  • Features: CORS, gzip compression, live reload injection
  • Only available in element mode via typedserver property

Common Issues to Watch For

  • The test mode runs test2 script, not test
  • Website mode restarts the entire server process on backend changes
  • Element mode rebuilds and reloads on any ts* folder change