CodeVetter · Repo Unpack · Extension points
swc-project/swc
SWC primarily extends through typed passes, visitor traits, feature-gated modules, and binding adapters. Plugins have a configurable sequence and an injectable execution runtime rather than a single permanently fixed backend. CLI operations follow a command enum and execution trait. Generated visitors and release carrier formats introduce additional maintenance contracts that extensions must preserve.
- Compiler::process_js_with_custom_pass accepts factories for before/after Pass implementations; its documented before-pass position follows decorators, resolver, and TypeScript stripping, and the after pass is appended to the built pass.
- Visit provides per-node traversal hooks, and overriding a method requires explicit child recursion; the generated visitor file directs maintainers to tools/generate-code rather than manual edits.
- JscExperimental.plugins stores ordered PluginConfig module-name/JSON-option pairs; plugin_env_vars and cache_root configure host inputs, and run_plugin_first moves plugin execution ahead of built-in transforms.
- RuntimeOptions::plugin_runtime accepts Arc<dyn Runtime>; Runtime implementers supply identifier, module preparation, initialization, and optional cache operations, with Wasmer chosen by the corresponding default feature.
- ModuleConfig is a tagged enum whose build function constructs module transformation passes; adding a format requires accounting for both the feature-enabled enum and the deserialization-only stub.
- Bundler inputs are replaceable through Load, returning SourceFile, Module, and Helpers; Resolve is separately re-exported, allowing loading and module resolution to evolve independently.
- CLI extensions plug into the Clap Command enum, implement CommandRunner::execute, and add dispatch in run; repository maintenance tasks use a separate xtask enum for Es, Bench, Git, Npm, and Clean.
- Legacy JavaScript Plugin callbacks remain composable through plugins(ps) but are deprecated in favor of WASM; native and wasm32/plugin-disabled builds have different plugin availability branches, including warning-and-skip behavior.