How aspect-build/rules_deno works
Key Components
• Bazel Core & Workspaces: At the base, you have the WORKSPACE file and multiple top-level Bazel configuration files (.bazelrc, BUILD.bazel, WORKSPACE) that define the build environment.
• Aspect Configurations: The .aspect folder (with subdirectories for bazelrc, cli, and workflows) encapsulates configuration rules and scripts that set up the build environment. This represents custom configuration and CI/CD pipelines.
• Deno Toolchain Integration: The “deno” directory contains files like defs.bzl, dependencies.bzl, and toolchain-related Starlark files that define how Deno interacts with Bazel. This component is crucial for translating Deno tasks into Bazel actions.
• Example and Test Workspaces: Under the e2e directory you have sample workspaces that demonstrate the concrete use of these rules (such as the “deno_binary” examples and the Fresh application) as well as testing setups.
• Utility and Tool Directories: The tools folder (with buildifier, format, gazelle, etc.) provides supporting utilities that help maintain the build files and format/validate the repository.
• Documentation & Examples: The docs directory (along with the README and CONTRIBUTING files) gives context on usage, showcasing how the rules should be applied.
Out the Relationships and Interactions
• The Bazel Workspace (root-level WORKSPACE and BUILD files) is the entry point and ties together all components.
• The custom rules defined in the “deno” directory are loaded in BUILD files across the project (as seen in the usage examples in the README where “deno_binary” is used).
• The .aspect configurations influence how Bazel runs actions (for instance, using different bazelrc configurations for debugging, performance, etc.) and also guide CI/CD workflows.
• e2e sample workspaces demonstrate how users can integrate Deno_script execution with Bazel actions (for both testing using sh_test and building executables with deno_binary).
• Utility tools ensure that build definitions remain consistent and compliant via automated formatting and linting.
Architectural Patterns and Design Principles
• Modular Design: The project is separated into clear modules – configuration, rule definitions, examples, tests, and tooling. This separation encourages modularity and reusability.
• Build-Time vs. Run-Time Separation: There is a clear distinction between the configuration and transformation of source code at build-time (using genrule, for instance) and the Deno scripts that run at runtime (whether as binaries or tests).
• Extensibility: The simplicity of the “deno_binary” rule and use of filegroup for libraries indicates that the system is designed to easily extend for more complex build patterns as needed.
• Integration with External Tools: The use of pre-commit hooks, CI configurations (.gitlab-ci.yml), and build tools (tools/format, tools/gazelle) emphasizes a robust integration ecosystem to maintain project health.