CodeVetter · Repo Unpack · Extension points
babel/babel
Plugins and presets are the main compiler extension contracts. Factories receive versioned APIs and cache controls, while plugin objects supply visitors and lifecycle hooks. Parser mixins, standalone registries, CLI option declarations, and worker action dispatch provide additional integration points. These mechanisms enforce ordering and compatibility constraints that extensions must preserve.
- PluginObject supports name, manipulateOptions, pre/post, inherits, visitor, parserOverride, and generatorOverride; validation rejects unknown properties and catch-all visitor enter/exit handlers.
- Plugin/preset factories receive api, options, and dirname; API construction includes cache, env, caller, targets, addExternalDependency, and plugin assumption access.
- Inherited plugins chain pre/post/manipulateOptions hooks, merge inherited and local visitors, and propagate inherited external dependencies with cache invalidation.
- PluginPass exposes per-pass Map state, file/options/cwd/filename/isAsync context, helper availability/insertion, and code-frame error construction.
- Parser/generator overrides may decline by returning undefined, but multiple returned results or Promise results throw; otherwise Babel uses its default parser/generator.
- Parser extensions compose ordered mixins for ESTree, JSX, Flow, TypeScript, V8 intrinsics, and placeholders; parser classes are cached by mixin names, and Flow/TypeScript cannot be combined.
- Standalone exposes registerPlugin(s) and registerPreset(s); duplicate names warn and replace registry entries, and processOptions resolves user-supplied names against those registries.
- CLI options extend through Commander declarations and babelOptions/cliOptions mapping; register worker functionality extends through the ACTIONS switch dispatching option, transform, ignore, and save requests.