CodeVetter · Repo Unpack · Data flow
babel/babel
Compilation begins with source text or a filename plus validated options. Configuration establishes absolute paths, targets, plugin descriptors, and ordered passes before parsing or transforming. Per-file state owns the AST, normalized options, metadata, and incoming map, then returns code and dependency information. CLI adapters write outputs, while register optionally caches compiled results across processes.
- loadPrivatePartialConfig validates input options, resolves cwd/root/filename, constructs an environment/caller context, builds the root chain, and resolves targets.
- buildRootChain merges root config, relative file config, and programmatic config in that precedence order; ignored files receive empty plugin/preset lists and fileHandling='ignored'.
- loadFullConfig expands preset descriptors into plugin passes, normally reversing preset order; explicit plugin descriptors are inserted first in the initial pass.
- transformFileRunner resolves configuration before reading UTF-8 source; a null configuration returns null without reading or compiling the input file.
- normalizeFile wraps Program roots as File nodes, rejects other roots, optionally clones supplied ASTs, or parses source; incoming maps come from an explicit object or trailing sourceMappingURL.
- run returns FileResult metadata, normalized options, optional AST/code/map, actual sourceType, and a freshly flattened externalDependencies Set after transformation.
- Directory output derives destination paths from input-relative paths and output-extension options, writes optional map sidecars before code, and copies permissions; file mode combines source maps with line offsets.
- Register cache keys hash serialized resolved options, Babel version, and environment; matching source mtime permits reuse, while new code/map values enter memory and compressed disk batches.