Mailglass.OptionalDeps (Mailglass v1.0.0)

Copy Markdown View Source

Namespace for optional dependency gateway modules.

Each submodule gates one optional dependency behind a Code.ensure_loaded?/1 check and exposes available?/0. The @compile {:no_warn_undefined, ...} declaration in each gateway module (and the corresponding project-level elixirc_options list in mix.exs) suppresses compiler warnings when the dep is absent, so mix compile --no-optional-deps --warnings-as-errors stays green across the full matrix.

Pattern (CORE-06)

  • Compile-time: @compile {:no_warn_undefined, [Module.Name, ...]} as the first declaration inside the gateway module, scoped to exactly the modules the gateway wraps.
  • Runtime: available?/0 delegates to Code.ensure_loaded?/1 so callers can branch between the real dep and a degraded fallback without compiling against the optional dep.

Gateway Modules

Lint Enforcement

Phase 6 ships a custom Credo check (NoBareOptionalDepReference) that flags any direct reference to the gated modules outside their corresponding gateway module. The gateway is the single authorized callsite.