[ast] 1f: Extract import/export/source merge into utils/fileMerge.ts
enhancement@kubb/core
Part of #3572 (Epic 1: separate concerns in the `@kubb/ast` utils layer).
## Goal
Move the import/export/source deduplication-and-merge logic out of `utils/ast.ts` into `src/utils/fileMerge.ts`. This also sets up Epic 2 #2a (clarifying the boundary against `dedupe.ts`).
## Functions to move (from `src/utils/ast.ts`)
- `combineImports`
- `combineExports`
- `combineSources`
- plus the private key/sort helpers: `sourceKey`, `pathTypeKey`, `exportKey`, `importKey`, `sortKey`, `mergeNameArrays`.
## Files
- New: `packages/ast/src/utils/fileMerge.ts` (+ `fileMerge.test.ts`).
- Edit: `packages/ast/src/factory.ts` — `createFile` imports `combineImports`/`combineExports`/`combineSources`; repoint to the new path.
- Edit: `packages/ast/src/utils/index.ts` if any of these are re-exported there (keep the surface identical).
## Acceptance
- `createFile` behaves identically (`factory.test.ts` green).
- `@kubb/ast` green; plugin snapshots byte-identical.
## Dependencies
None. After this, the only functions left in `utils/ast.ts` are the schema mutators `syncSchemaRef` and `createDiscriminantNode`, which Epic 2 #2b relocates to `transformers.ts`; `utils/ast.ts` is deleted at the end of #2b.
关闭于 2026-06-14 0 条评论