Compare clj-reload with tools.namespace
mainWhile both clj-reload and tools.namespace track file modification times and reload namespaces in topological order, clj-reload provides several advantages for a smoother development workflow:
- Selective Reloading: Unlike
tools.namespacewhich reloads every namespace it finds,clj-reloadonly reloads namespaces that were already loaded. This prevents experimental or broken files from breaking your workflow. - Efficient First Reload: The very first reload in
clj-reloadonly reloads files that have actually changed, whereastools.namespacereloads everything on the first pass. - Advanced Dependency Tracking: Supports namespaces split across multiple files and can detect dependencies in top-level standalone
requireanduseforms. - Lifecycle Hooks: Supports per-namespace load and unload hooks, allowing you to manage state more precisely than
tools.namespace. - State Preservation: Can keep individual vars around and restore previous values after a reload (making it compatible with patterns like
defonce). - Configuration: Allows specifying exclusions during configuration without modifying the source code of the namespaces being excluded.
- Lightweight: Has a significantly smaller codebase and zero runtime dependencies.