code-docs/architecture/module-fetching.md
How module sources are fetched and cached during the build.
Module fetching runs inside the build process (Phase 0), not the CLI. Unlike plugins (which need npm installation into the server's node_modules), modules are YAML files on disk. Running fetching within the build avoids the subprocess boundary problem — resolved paths stay in-process and pass directly to registerModuleEntry.
File: packages/build/src/build/parseModuleSource.js
The source field follows the GitHub Actions convention:
github:{owner}/{repo}@{ref} → root of repo
github:{owner}/{repo}/{path}@{ref} → subdirectory in repo
file:{relative/path} → local directory
Since GitHub repos are always owner/repo (two segments), parsing is unambiguous — additional segments are the subdirectory path, @ref is the git ref.
For github: sources, the build:
https://api.github.com/repos/{owner}/{repo}/tarball/{ref}.lowdefy/modules/github/{owner}/{repo}/{ref}/Cache directory: .lowdefy/modules/
.lowdefy/modules/
└── github/
└── {owner}/
└── {repo}/
└── {ref}/
├── module.lowdefy.yaml
├── pages/
└── ...
When multiple module entries reference the same repo and ref (e.g., two modules from a monorepo), the tarball is fetched once. Each entry resolves to its own subdirectory within the cached repo.
file: Resolutionsource: "file:../../modules/user-admin" resolves relative to the directory containing lowdefy.yaml. No caching or fetching — reads directly from disk. File changes are visible immediately on rebuild.
The build checks for credentials in order:
GITHUB_TOKEN environment variable — used as Bearer tokengh CLI token — extracted from gh auth token if availableFor private repositories, GITHUB_TOKEN is the recommended approach. Set it in .env for local development.
For local sources (file: paths), the dev server's file watcher covers the resolved module directory. Changes to module files trigger a rebuild — the same behavior as changes to app config files.
GitHub sources are not watched — they are fetched once per build. To iterate on a GitHub-hosted module, use a local file: source during development.
| File | Purpose |
|---|---|
packages/build/src/build/fetchModules.js | Orchestrates module fetching |
packages/build/src/build/parseModuleSource.js | Parses github: and file: source strings |