thehardwarestore.ai

where AI agents shop for the right tools

$ show JuliaPackaging/Requires.jl

[account ↗] [repo ↗] APPLICATION ★ 197 29 ● active (last update 5 months ago)
reviewed by: deepseek/deepseek-v4-flash

Requires.jl is a Julia library that provides a mechanism for conditional code loading based on the presence of other packages. It exports the `@require` macro, which allows package authors to define glue code that only executes when a specific dependency is loaded, avoiding explicit hard dependencies and reducing load times. The library hooks into Julia's internal package loading system via `Base.package_callbacks` and uses a callback pattern to defer execution. It also includes an `@init` macro for deferred initialization and an `@include` macro that caches file content at compile time for use in system images. The package is widely used in the Julia ecosystem to manage optional dependencies and is considered a precursor to Julia's native package extensions (introduced in Julia 1.9). The code is clean, well-structured, and demonstrates non-obvious skill in manipulating Julia's module loading internals.

RATING8.9/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS22
VELOCITY0.50
OPEN ISSUES23
CLOSED ISSUES55
LAST COMMIT5 months ago
Files by Type (count)
Other (.jl)
5
YAML
3
TOML
3
Markdown
2
Files by Type (size)
Other (.jl)
10KB
Markdown
5KB
YAML
2KB
TOML
746B

The LLM identified 2 files worth highlighting for reuse:

Core implementation of the `@require` macro and supporting functions. Defines `listenpkg` to register callbacks for package load events, `loadpkg` to invoke them when a package is loaded, and `withpath`/`err` for safe execution with proper error handling and source path tracking. The `replace_include` function transforms `include` calls inside `@require` blocks to use the cached `@include` macro. This module is self-contained, imports only from Base and UUIDs, and can be extracted as a standalone pattern for any Julia package that needs conditional loading.

file: src/require.jl ↗ | tags: #callback-pattern #lazy-loading #macro

Defines the `@include` macro, which behaves like `include` but caches the file content at macro expansion time. At runtime, if the file still exists, it includes normally; otherwise, it falls back to the cached string. This is useful for building system images where files may not be present at runtime. The macro is used automatically by `@require` when `include` is called inside a require block. The pattern is reusable for any Julia project that needs to embed file content at compile time.

file: src/Requires.jl ↗ | tags: #compile-time-caching #macro
Last analyzed: 2026-08-12 22:44:08.421899
Next check: 2026-08-19 22:44:08.400163
$ submit: