HASSL is a compiler for the Home Assistant Simple Scripting Language (DSL) that transforms .hassl files into Home Assistant automation packages. The system parses HASSL syntax using Lark, resolves imports and packages, performs semantic analysis to build an intermediate representation, and generates YAML output including helpers, scripts, sync automations, rule automations, and schedule sensors. Key features include loop-safe context tracking, per-rule enable gates, template-based code reuse, and comprehensive schedule support with window syntax and holiday integration. The architecture is modular with distinct phases: parsing, transformation, analysis, and code generation, each handled in separate modules. The CLI orchestrates the process, handles dependency loading of imported files, and writes output to a directory structure suitable for Home Assistant's packages folder.
This is a webpack loader that compiles Stylus (.styl) files into CSS. It acts as a bridge between the webpack build system and the Stylus CSS preprocessor, handling import resolution (including glob patterns, node_modules, webpack aliases, and tilde imports), source maps, custom Stylus options, and URL rewriting. The architecture follows the standard webpack loader pattern: it receives the source code, parses options via a JSON schema, renders Stylus using an implementation (defaulting to the `stylus` package), and outputs either the compiled CSS along with source map and dependency list. It supports dual ESM/CJS builds and is compatible with webpack 5 and optionally Rspack. The primary entry point is `src/index.js`, which exports the loader function. Core utilities live in `src/utils.js`, which includes a custom Stylus evaluator that overrides import resolution to delegate to webpack's resolver, utility functions for normalizing options and source maps, and a dependency collector that traverses the Stylus AST to report all imports to webpack's build graph. The loader integrates deeply with webpack's module resolution (aliases, `resolve.byDependency`, custom conditions) and supports advanced Stylus features like CSS module exports, `@import` and `@require`, `@block`, and the `url()` resolver. Externally, it depends on the `stylus` npm package as the core preprocessor, and on webpack's loader API. It is actively maintained, with recent major version bumps aligning with Node.js runtime requirements (v9.0.0 requires Node >=22.11.0). The codebase is well-tested with a comprehensive test suite covering numerous edge cases in import resolution, error handling, and option combinations. While the loader itself is webpack-specific, several internal patterns (custom evaluator, dependency resolution, URL handling) demonstrate non-obvious craftsmanship and could inform similar integrations for other CSS preprocessors.