- **v0.5.340** — Tier 2.1 + 2.2 mass follow-up: completes the lower_call.rs split with the 805-LOC `lower_native_method_call` that v0.5.339 deferred, plus the next four big chunks of compile.rs (per-target codegen orchestrators, on-disk object cache, npm/module resolution). Four extractions in one PR. **lower_call.rs `lower_native_method_call`** (1 new sub-module, 805 LOC moved): `lower_call/native.rs` is the giant dispatcher routing `obj.method(args)` calls against native modules (mysql2, pg, redis, mongo, ws, fastify, fetch, perry/ui, perry/system, perry/i18n, perry/plugin, AbortController, …). Required bumping 14 helpers in `lower_call.rs` from private `fn` to `pub(super) fn` so the new sub-module can reach them via `super::` (perry_*_table_lookup family — UI / UI_INSTANCE / SYSTEM / I18N / PLUGIN / PLUGIN_INSTANCE — plus native_module_lookup, lower_perry_ui_table_call, lower_fetch_native_method, lower_abort_controller_call, lower_notification_schedule, find_outer_writes_stmt, is_abort_controller_expr, lower_native_module_dispatch, collect_closure_introduced_ids). The fn itself is `pub(crate)` (re-exported from lower_call.rs for callers in `crate::expr` that import directly). **compile.rs per-target orchestrators** (1 new sub-module, ~800 LOC moved): `compile/targets.rs` contains the 6 `compile_for_*` widget/web/wasm functions (ios_widget, watchos_widget, android_widget, wearos_tile, web, wasm) plus their supporting helpers (`generate_js_bundle`, `find_watchos_swift_runtime`, `find_visionos_swift_runtime`, `apple_sdk_version`, `lookup_bundle_id_from_toml`, `compile_metallib_for_bundle`). 12 fns hoisted to `pub(super)`. **compile.rs object cache** (1 new sub-module, ~440 LOC moved): `compile/object_cache.rs` contains `djb2_hash` + `Djb2Hasher` (the streaming hash accumulator) + `compute_object_cache_key` (the 246-LOC opts→key derivation) + the `ObjectCache` struct + impl + the 282-LOC `object_cache_tests` mod. Cluster moved together because they all relate to the V2.2 `.perry-cache/objects/<target>/<key>.o` codegen cache layout. `djb2_hash` re-exported as `pub` (used elsewhere in compile.rs); `compute_object_cache_key` is now `pub fn` so the resolve.rs sub-module's `cached_resolve_import` can keep calling it. **compile.rs resolve_import family** (1 new sub-module, ~810 LOC moved): `compile/resolve.rs` is the entire TypeScript / JavaScript module-resolution machinery: `find_perry_workspace_root` (workspace-marker walk), `find_node_modules` (walk-up search), `find_file_dep_in_package_json` (issue #209 file: dep resolution), `parse_package_specifier` / `resolve_with_extensions` / `resolve_package_entry` / `resolve_package_source_entry` / `resolve_exports` (per-segment resolution), `resolve_import` + `cached_resolve_import` (public entry + cache), `discover_extension_entries`, `compute_module_prefix`, plus the npm-package classification helpers (`has_perry_native_library`, `has_perry_native_module`, `parse_native_library_manifest`, `is_in_perry_native_package`, `extract_compile_package_dir`, `is_in_compile_package`) and the file-extension predicates (`is_js_file`, `is_ts_file`, `is_declaration_file`). 17 fns hoisted to `pub(super)` or `pub`. **Cumulative deltas this commit**: lower_call.rs 5085 → 4681 LOC (-404, ~8%); compile.rs 8057 → 5795 LOC (-2262, ~28%). **Cumulative across the entire session** (v0.5.329-v0.5.340): compile.rs 9391 → 5795 LOC (~38% reduction), lower_call.rs 7000+ → 4681 LOC (~33%), lower.rs 13591 → 7554 LOC (~44%), `lower::lower_expr` (the most-cited monolith) 6687 → 624 LOC (~91%). The single biggest cognitive-load reduction in the project's history. **What's still inline in compile.rs** (5795 LOC): the orchestrator entry points (`run`, `run_with_parse_cache`), context construction (`CompilationContext::new`), library/runtime building (`build_optimized_libs`, ~270 LOC), the link command construction (`build_link_command` and the inline body of `run_with_parse_cache`, the bulk of remaining LOC), and the v0.5.295 `find_clang` + Linux LLVM-prefix fallback. Each is independently extractable but doing more would shift this PR into rewrite-territory. **Verified**: cargo build --release clean; cargo test --workspace 434/0 = baseline; gap tests 25/28 = baseline; doc-tests --skip-xcompile 80/82 = baseline; comprehensive UI smoke (`App({ title, body: VStack([Text("OK"), Button("Click", () => {})]) })`) compiles to 0.9 MB binary, exits 0 in `PERRY_UI_TEST_MODE=1`, and the strip-dedup output (419 → 35 trimmed objects) matches v0.5.331 exactly — proves the live path through library_search + targets + strip_dedup + ObjectCache + resolve all works end-to-end. Multi-module #212 closure-capture smoke matches Node byte-for-byte. **Cumulative across this session** (v0.5.329-v0.5.340, twelve commits): every plan item delivered as full or pilot work, plus three rounds of follow-up extractions completing most of the cognitive-load reductions the plan called out.
0 commit comments