Skip to content

l0.DependencyControl.ModuleLoader

ModuleLoader = require "l0.DependencyControl.ModuleLoader"
local ModuleLoader = require("l0.DependencyControl.ModuleLoader")

ModuleLoader

Internal module loading helpers for DependencyControl-managed module dependencies.

Class methods

formatVersionErrorTemplate

ModuleLoader\formatVersionErrorTemplate name, reqVersion, url, reason, ref
ModuleLoader:formatVersionErrorTemplate(name, reqVersion, url, reason, ref)

Formats a single module's version-error line for a load-error summary.

param type description
name string The module's display name.
reqVersion? string|integer The required version, shown in the message when present.
url? string The module's feed/download URL, appended when present.
reason? string The failure reason shown for the module.
ref? table The installed module's version record; when given, formats the outdated template instead of the missing one.

Returns:

  • errorLine string — The formatted one-line error entry.

createDummyRef

ModuleLoader\createDummyRef!
ModuleLoader:createDummyRef()

Registers a placeholder entry for this module in the global module registry so a circular dependency can resolve this module while it is still loading. No-op for non-module scripts.

Returns:

  • registered boolean|nil — True if a dummy was registered, false if one already existed, nil if this isn't a module.

removeDummyRef

ModuleLoader\removeDummyRef!
ModuleLoader:removeDummyRef()

Removes this module's placeholder registry entry if it is still a dummy (not yet replaced by the real module). No-op for non-module scripts.

Returns:

  • removed boolean|nil — True if a dummy entry was removed, false if none was present, nil if this isn't a module.

loadModule

ModuleLoader\loadModule mdl, usePrivate, reload
ModuleLoader:loadModule(mdl, usePrivate, reload)

Loads a single required module, storing the result in mdl._ref and running its DependencyControl initializer. On failure, sets mdl._missing when the module wasn't found or mdl._error with the load error.

param type description
mdl table The module descriptor to load; mutated in place with the result and error flags.
usePrivate? boolean Load this script's private copy (namespaced under its own name) instead of the shared module.
reload? boolean Discard cached references to the module and its submodules and load afresh.

Returns:

  • ref table? — The loaded module reference, or nil on failure.

loadModules

ModuleLoader\loadModules modules, addFeeds, skip
ModuleLoader:loadModules(modules, addFeeds, skip)

Loads required modules, updates missing/outdated ones, and validates version constraints.

param type description
modules table[]
addFeeds? string[] Extra feed URLs to search when fetching missing modules (default: this script's feed).
skip? table<string, boolean> Module names to skip, keyed by name (default: this module itself).

Returns:

  • success boolean
  • err string — Combined error message (empty on success).

checkOptionalModules

ModuleLoader\checkOptionalModules modules
ModuleLoader:checkOptionalModules(modules)

Validates optional module availability for the requested feature set.

param type description
modules string|string[] Feature name(s) whose optional modules to check.

Returns:

  • available boolean
  • err string? — Error message listing missing modules.