# Behavior traces — swc-project/swc

> Canonical page: https://codevetter.com/unpack/swc/behavior-traces

# Behavior traces — 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.

The inspected flows trace concrete calls across JavaScript, native bindings, compiler configuration, and output boundaries. Startup includes platform selection and, for carrier packages, verified materialization before dynamic loading. Transformation and AST round-tripping take different compiler ownership branches. Minification and CLI output provide additional complete paths with explicit failure conditions.
- Startup: the core module reads SWC_BINARY_PATH, requires that path or binding.js, checks getTargetTriple, and attempts @swc/wasm on an exception; the generated loader detects Linux libc through filesystem, process-report, then child-process probes. — [packages/core/src/index.ts#L21-43](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L21-L43) [packages/core/binding.js#L10-21](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/binding.js#L10-L21) [packages/core/binding.js#L26-56](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/binding.js#L26-L56)
- Carrier startup: napi_register_module_v1 calls initialize → Payload::parse/with_integrity → CacheMode::from_env → optional try_replace or cache::materialize → OS library load → resolve raw napi_register_module_v1 → materialized.loaded; the raw registration function then receives the original Node pointers. — [bindings/binding_native_addon/src/lib.rs#L51-117](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_native_addon/src/lib.rs#L51-L117) [bindings/binding_native_addon/src/lib.rs#L133-154](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_native_addon/src/lib.rs#L133-L154)
- Persistent materialization: cached_at creates the secure namespace, obtains namespace/per-image locks, opens and verifies an existing image, or decodes and verifies a staging file before atomic replace_file; special-file errors return without repair. — [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_native_addon/src/cache.rs#L115-124](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_native_addon/src/cache.rs#L115-L124)
- Text transformation: Compiler.transform → bindings.transform → AsyncTask<TransformTask> → compute → new_source_file → Compiler::process_js_file; a legacy JS plugin instead parses first, invokes plugin(m), copies source context, and recursively transforms without the plugin option. — [packages/core/src/index.ts#L295-326](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L295-L326) [bindings/binding_core_node/src/transform.rs#L120-130](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/transform.rs#L120-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)
- Compiler pipeline: process_js_file → process_js_with_custom_pass → parse_js_as_input → read_config/build_as_input → apply_transforms → print; a configuration-excluded input produces 'cannot process file because it’s ignored by .swcrc'. — [crates/swc/src/lib.rs#L967-1005](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L967-L1005) [crates/swc/src/lib.rs#L1010-1024](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L1010-L1024) [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#L1317-1351](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L1317-L1351)
- AST round-trip: ParseTask::compute creates source/comments → parse_js → resolver → serialize_program; parseProgramJson attaches context, then print calls stringifyProgram → PrintTask::compute → deserialize_program_input → fresh compiler for context-bearing input → prepare_program_with_context → Compiler::print. — [bindings/binding_core_node/src/parse.rs#L43-79](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/parse.rs#L43-L79) [packages/core/src/index.ts#L97-125](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L97-L125) [packages/core/src/index.ts#L267-274](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L267-L274) [bindings/binding_core_node/src/print.rs#L31-79](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/print.rs#L31-L79)
- Minification: Compiler.minify → native minify → MinifyTask::compute → MinifyTarget::to_file → Compiler::minify → parse_js → paren_remover/resolver → optimize → hygiene when mangling is disabled → fixer → comment handling → print. — [packages/core/src/index.ts#L149-154](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/packages/core/src/index.ts#L149-L154) [bindings/binding_core_node/src/minify.rs#L66-75](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/binding_core_node/src/minify.rs#L66-L75) [crates/swc/src/lib.rs#L1086-1103](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L1086-L1103) [crates/swc/src/lib.rs#L1136-1179](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc/src/lib.rs#L1136-L1179)
- CLI compilation: main → run → CompileOptions::execute → validate → execute_once or a watch handler; stdout mode collects inputs, calls execute_transform/process_js_file, then emit_stdout_output, while directory mode processes output entries in parallel. — [bindings/swc_cli/src/main.rs#L1-3](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/bindings/swc_cli/src/main.rs#L1-L3) [crates/swc_cli_impl/src/lib.rs#L7-16](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_cli_impl/src/lib.rs#L7-L16) [crates/swc_cli_impl/src/commands/compile.rs#L896-931](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_cli_impl/src/commands/compile.rs#L896-L931) [crates/swc_cli_impl/src/commands/compile.rs#L1193-1213](https://github.com/swc-project/swc/blob/3c46139b86b27a7b3fefcf7b19ca07a63de9db0a/crates/swc_cli_impl/src/commands/compile.rs#L1193-L1213)

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)
