Skip to content

refactor(core): move compile facade out of index.ts barrel - #2038

Merged
kompiro merged 3 commits into
mainfrom
refactor/core-facade-extraction
Jul 17, 2026
Merged

kompiro merged 3 commits into
mainfrom
refactor/core-facade-extraction

Conversation

@kompiro

@kompiro kompiro commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Second point of the packages/core refactoring plan in #2014 (point 1/3/7/8 landed in #2026). Moves the ~1,480-line compile-pipeline implementation out of packages/core/src/index.ts into two new deep-path modules under packages/core/src/compile/, using oxlint's no-restricted-imports rule (barrel imports forbidden inside packages/core/src/**) as the guardrail.

index.ts now only re-exports this surface (export { ... } from "./compile/compile.js" / "./compile/compile-diff.js") alongside its existing barrel exports. Same names, same types — zero behavior change. Only import paths were adjusted from ./x to ../x; no logic was touched.

Also fixed two ADR machine-checkable grep: assumptions (ADR-20260616-01, ADR-20260714-04) that pointed at text now living in compile/compile.ts instead of index.ts.

Why this split (and not more)

compile.ts and compile-diff.ts have no interdependency (each imports directly from renderer/, view/, resolver/, fs/, builtins/, diff/) so there's no risk of a cycle between them, confirmed by pnpm check:cycles. NodeMetadata, PreparedCompileInput, buildNodeMetadata, buildDeployNodeMetadata, diagnosticToWarning, and the diff helpers stay private (not re-exported) — they were never part of the public surface.

Verification

Gate Result
pnpm --filter @karasu-tools/core test ✅ 94 files, 2322 tests passed
pnpm typecheck (full repo, all 9 packages) ✅ pass
pnpm check:cycles ✅ no circular dependency
pnpm knip ✅ zero unused exports (only the pre-existing @resvg/resvg-wasm config hint, unrelated)
pnpm lint ✅ 0 warnings / 0 errors
pnpm adr:check-assumptions ✅ 477 OK, 0 failing (1 pre-existing manual-review, unrelated)
Byte-identity render check ✅ see below

Byte-identity render check

Wrote a harness (tsx script importing @karasu-tools/core's index.ts directly, once pointed at main and once at this branch) that renders every bundled example project via buildAllViewsSvgProject in both default and icon display modes:

  • 52/52 bundled SVGs byte-identical (diff -rq exit 0) across all example projects (getting-started, deploy-only, org-only, client-mcp, feature-samples, multi-file-system, all ec-platform variants, ja + en).
  • Diagnostics arrays (JSON.stringify) also byte-identical for all 52 renders.

Separately exercised the relocated compile/compile-diff.ts facade specifically (not covered by the non-diff harness above): rendered buildAllViewsSvgDiffProject for 4 example projects × 2 display modes (before = full project, after = truncated copy, to exercise added/removed/changed diff states across system/deploy/org views) — 8/8 diff SVGs + diff-metadata JSON byte-identical between main and this branch.

No changeset: internal refactor only, the public export surface (index.ts) is unchanged in names and types.

Refs #2014

🤖 Generated with Claude Code

kompiro added 3 commits July 17, 2026 10:29
Relocates the ~1,480 lines of compile-pipeline implementation from
packages/core/src/index.ts into two new deep-path modules:

- src/compile/compile.ts: CompileOptions/CompileResult types,
  _compileFromPreparedInput/_compileCore/_compileProjectCore,
  compile()/compileProject() overloads, the deprecated
  compileOrgView()/compileProjectOrgView() wrappers,
  buildNodeMetadata/buildDeployNodeMetadata, the multi-level SVG
  builders (buildDrillDownSvg, renderEntityView, buildAllLayersSvg*,
  buildDrillDownSvgOrg, buildAllViewsSvg, buildAllViewsSvgProject),
  and diagnosticToWarning.
- src/compile/compile-diff.ts: the diff-compile facade
  (resolveBeforeAfter/assembleDiffSheets/toDiffStateMaps helpers
  extracted in the first #2014 batch, compileSystemDiff,
  compileDeployDiff, compileOrgDiff, buildAllViewsSvgDiffProject).

index.ts now only re-exports this surface (`export { ... } from
"./compile/compile.js"` / "./compile/compile-diff.js"`) alongside its
existing barrel exports — same names, same types, zero behavior
change.

Refs #2014 (point 2)
…facade move

- oxfmt reformats compile-diff.ts (multi-line import wrap)
- ADR-20260616-01 / ADR-20260714-04 machine-checkable "grep" assumptions
  pointed at packages/core/src/index.ts for text that now lives in
  packages/core/src/compile/compile.ts after the facade extraction

Refs #2014 (point 2)
…extraction

# Conflicts:
#	packages/core/src/index.ts
@kompiro
kompiro merged commit f04d532 into main Jul 17, 2026
12 checks passed
@kompiro
kompiro deleted the refactor/core-facade-extraction branch July 17, 2026 14:06
kompiro added a commit that referenced this pull request Oct 31, 2026
…ations (#3425)

* docs(tpl): 2026-10 deprecation review, refresh 15 TPLs with stale citations

Repoint line-number citations whose code moved (index.ts split in #2038,
needsQuotes rewrite in #2707, diagLocFormatter in #2715, spec/CSS drift),
drop citations of sites the VS Code shared viewer removed (#3312), record
that the gh-aw consumer of TPL-2658/TPL-2786 left in #3423, and drop the
"experimental" facet headings that language v2.0 removed (#2677).

Refs #3357

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(tpl): address local review on the 2026-10 TPL review

Correct the BARE_ID_PATTERN history in TPL-1101 (the keyword copy was
RESERVED_KEYWORDS), repoint TPL-239's drifted cli/index.ts:442 citation to
program.parseAsync, drop an em dash in TPL-1503, and place TPL-2996's
origin section before the known patterns like TPL-2658/TPL-2786.

Refs #3357

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(tpl): name #3423 as the gh-aw removal in absent-path markers

#3421 tracks the revival; the workflows and their safety test were
removed by #3423 (ADR-3421).

Refs #3357

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(tpl): drop TPL-2791's citation of the function #3422 removed

detectCyclicDependencies left warnings.ts when #3422 moved the cyclic flag
to model construction; the TPL body already names findCyclicDependencies
and markCyclicEdges in parser/cyclic-dependencies.ts.

Refs #3357

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was successfully deployed

1 active deployment
preview — dbabc69c Deployed Jul 17, 2026 by github-actions[bot]
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