# Data flow — swc-project/swc

> Canonical page: https://codevetter.com/unpack/swc/data-flow

# Data flow — swc-project/swc

Scanned commit 3c46139b86b27a7b3fefcf7b19ca07a63de9db0a (2026-10-02). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

JavaScript requests cross the native boundary as source strings, serialized Programs, and JSON option buffers. Compiler instances own source maps, while AST envelopes preserve enough original source information to restore positions across calls. Configuration builds the transformation pass and output metadata before code generation. Persistent state mainly appears in native image and plugin caches; CLI handlers separately own generated-file writes.
- toBuffer serializes options with JSON.stringify; transform classifies non-string input as a Program and uses stringifyProgram before calling the native binding. — [packages/core/src/index.ts#L295-326](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L295-L326) [packages/core/src/index.ts#L632-634](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L632-L634)
- Native transform chooses Input::Program with the shared compiler or Input::Source with a fresh compiler; TransformTask::compute deserializes options, adjusts filename-dependent config, and reads files or creates SourceFiles before compilation. — [bindings/binding_core_node/src/transform.rs#L85-130](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/transform.rs#L85-L130) [bindings/binding_core_node/src/transform.rs#L146-161](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/transform.rs#L146-L161)
- parse serializes ProgramEnvelope with source text, real filename, and byte bounds; JavaScript stores sourceContext on a non-enumerable Symbol and includes it again only when serializing the Program for native consumption. — [bindings/binding_core_node/src/ast_context.rs#L13-55](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/ast_context.rs#L13-L55) [packages/core/src/index.ts#L57-79](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L57-L79) [packages/core/src/index.ts#L97-125](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L97-L125)
- Context-bearing ASTs restore a SourceFile, require its byte length to match the original range, and rebase positions; out-of-range spans become DUMMY_SP, while dummy and reserved positions are preserved. — [bindings/binding_core_node/src/ast_context.rs#L72-97](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/ast_context.rs#L72-L97) [bindings/binding_core_node/src/ast_context.rs#L140-175](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/ast_context.rs#L140-L175)
- parse_js_as_input first applies filename matching, then read_config, then Options::build_as_input; explicit config paths bypass discovery, and RootMode::Upward errors when no .swcrc is found. — [crates/swc/src/lib.rs#L875-910](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L875-L910) [crates/swc/src/lib.rs#L737-773](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L737-L773)
- apply_transforms captures auxiliary output while applying the configured pass under HELPERS and HANDLER, optionally downgrades a Flow type-only module, filters comments, and forwards source-map settings to print. — [crates/swc/src/lib.rs#L1317-1363](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L1317-L1363)
- WASM plugins receive a versioned serialized Program; outputs feed the next plugin as serialized bytes, and the host deserializes once after the configured sequence finishes. — [crates/swc/src/plugin.rs#L130-164](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/plugin.rs#L130-L164) [crates/swc/src/plugin.rs#L174-189](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/plugin.rs#L174-L189)
- Native images persist in a user/version namespace under a digest filename, using locks and staging replacement; compiler printing itself does not write its target path, whereas CLI emit_directory_output writes code, maps, and optional declarations. — [crates/swc_native_addon/src/cache.rs#L115-124](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_native_addon/src/cache.rs#L115-L124) [crates/swc_native_addon/src/cache.rs#L312-358](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_native_addon/src/cache.rs#L312-L358) [crates/swc/src/lib.rs#L695-699](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L695-L699) [crates/swc_cli_impl/src/commands/compile.rs#L400-432](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_cli_impl/src/commands/compile.rs#L400-L432)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
