Zeitwerk Internals
summary
Zeitwerk is an autoloader/reloader/eager loader implemented in ~1,000 lines with about 50 releases and ~300 million downloads on RubyGems; it scans only one directory level at setup, registers absolute-path autoloads, wraps require with a registry to intercept files and directories, creates modules on demand, uses an inflector per loader, eager loads breadth‑first by triggering pending autoloads, and handles reloads by removing constants and entries from loaded_features plus a TracePoint‑based explicit-namespace mechanism.
AI-written summary · about
chapters (12)
- 0:00Introduction and welcome
- 1:04Speaker introduction
- 4:34Ruby constants and autoloading basics
- 17:27Zeitwerk setup and conventions
- 20:40Autoloading implementation
- 32:36How autoloads are executed
- 33:43Zeitwerk's require wrapper
- 42:36Recursive autoloading and name spaces
- 46:13Explicit name spaces and TracePoint
- 49:28Eager loading mechanics
- 52:44Reloading process
- 56:15Summary and closing








