Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(deps): gazelle migration phases 2-3 — decompose ts_compile and vitest macros#6198

Merged
longlho merged 2 commits into
mainfrom
chore/gazelle-migration-phase2
Mar 29, 2026
Merged

refactor(deps): gazelle migration phases 2-3 — decompose ts_compile and vitest macros#6198
longlho merged 2 commits into
mainfrom
chore/gazelle-migration-phase2

Conversation

@longlho
Copy link
Copy Markdown
Member

@longlho longlho commented Mar 29, 2026

Summary

Gazelle migration phases 2 and 3: decompose all custom macros (ts_compile, ts_compile_node, vitest) into explicit ts_project + js_library / vitest_runner targets. This makes all ts_project targets visible at the BUILD file level — the prerequisite for gazelle to manage deps by reading TypeScript imports.

Phase 2: Decompose ts_compile / ts_compile_node

Each macro call expanded to 3 explicit targets:

ts_project(
    # Type-check only (tsgo, no emit)
    name = "dist-esm-typecheck", ...
)
ts_project(
    # Transpile to JS + .d.ts (oxc-transform)
    name = "dist-esm", ...
)
js_library(name = "dist", srcs = [":dist-esm", "package.json"])
  • 21 ts_compile packages (BASE_TSCONFIG) + 1 custom (BASE_NODE_TSCONFIG)
  • 7 ts_compile_node packages (ESNEXT_TSCONFIG)
  • 29 BUILD.bazel files modified

Phase 3: Decompose vitest

Created vitest_runner macro in tools/vitest.bzl (test runner + snapshots only, no ts_project). Inlined ts_project typecheck into BUILD files:

ts_project(
    # Type-check only (tsgo, no emit)
    name = "unit_test_typecheck",
    deps = SRC_DEPS + VITEST_DEPS, ...
)
vitest_runner(name = "unit_test", srcs = ..., deps = ...)
  • Exported TEST_TSCONFIG, VITEST_DEPS, VITEST_DOM_DEPS from vitest.bzl
  • 40 vitest calls across 34 BUILD.bazel files migrated
  • Old vitest macro kept as deprecated wrapper for backwards compatibility

What's NOT changed (Phase 4)

  • npm_package, esbuild, generate_src_file, generate_ide_tsconfig_json — packaging/codegen stays manual
  • tools/index.bzl — old macros remain for reference

Test plan

  • pnpm t — all 495 tests pass
  • All lefthook hooks pass (buildifier, gazelle 0 files updated)
  • CI passes

🤖 Generated with Claude Code

longlho and others added 2 commits March 28, 2026 20:46
Inline all ts_compile() and ts_compile_node() macro calls into explicit
ts_project + js_library targets across 29 BUILD.bazel files. Each macro
call expanded to 3 targets:
- ts_project (typecheck only, tsgo transpiler, no_emit)
- ts_project (transpile with oxc, emits JS + .d.ts)
- js_library (bundles transpiled output + package.json)

This makes ts_project targets visible at the BUILD file level, which is
a prerequisite for gazelle to manage their deps automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@longlho longlho enabled auto-merge (squash) March 29, 2026 00:50
@longlho longlho merged commit 0b241f3 into main Mar 29, 2026
6 checks passed
@longlho longlho deleted the chore/gazelle-migration-phase2 branch March 29, 2026 00:52
@longlho longlho changed the title refactor(deps): gazelle migration phase 2 — decompose ts_compile macros refactor(deps): gazelle migration phases 2-3 — decompose ts_compile and vitest macros Mar 29, 2026
longlho added a commit that referenced this pull request Mar 30, 2026
Revert the BUILD file changes from phases 1-3 of the gazelle migration:
- Phase 1: inline ts_binary -> js_binary (#6197)
- Phase 2: decompose ts_compile macros (#6198)
- Phase 3+4: decompose vitest, enable gazelle JS (#6199)

Keep gazelle scaffolding (aspect-gazelle setup, multitool, lefthook
integration) and knowledge-base documentation.

The migration approach of using map_kind + copy_to_bin caused
conflicting actions between gazelle-managed srcs and copy_to_bin
outputs. A different approach is needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
longlho added a commit that referenced this pull request Mar 30, 2026
## Summary

Revert the BUILD file changes from the gazelle migration (phases 1-3)
while keeping the scaffolding and documentation.

### Reverted
- Phase 1: `ts_binary` → `js_binary` inlining (#6197)
- Phase 2: `ts_compile` macro decomposition (#6198)
- Phase 3+4: `vitest` decomposition + gazelle JS enablement (#6199)

### Kept
- Gazelle scaffolding: aspect-gazelle setup, multitool, lefthook
integration (#6195)
- Knowledge-base documentation (#6196)

### Why

The `map_kind` + `copy_to_bin` approach caused conflicting actions —
both `copy_to_bin(name = "srcs")` and gazelle's direct file lists
produce the same output files through `ts_project`. A different approach
is needed that either eliminates `copy_to_bin` or uses a custom gazelle
extension.

## Test plan
- [x] 495 tests pass
- [ ] CI passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant