feat(ast): /types subpath, concurrent walk(), and a trimmed public API#3402
Merged
Conversation
The README documents `import ... from '@kubb/ast/types'`, but the subpath was never wired into the package exports, so the import failed. Add a `types` tsdown entry so the type-only subpath is emitted and exported. `walk()` awaited each child sequentially, so its documented `concurrency` option never parallelized anything — async visitor callbacks always ran one at a time. Traverse siblings via the shared limiter instead, so the limit is honored, and tighten the test to assert real parallelism. https://claude.ai/code/session_01UHmX1Z5cshiSKjzPoExazB
@kubb/adapter-oas
@kubb/agent
@kubb/ast
@kubb/cli
@kubb/core
kubb
@kubb/mcp
@kubb/middleware-barrel
@kubb/parser-md
@kubb/parser-ts
@kubb/renderer-jsx
unplugin-kubb
commit: |
Remove exports that are unused across both this monorepo and the plugins repo, and that duplicate or back a public counterpart: - delete dead constants `nodeKinds` and `mediaTypes` (no references) - delete the `RefMap` type and the `InferSchema` alias (use InferSchemaNode) - stop exporting `collectLazy` (use eager `collect`) and the `createContent` / `createRequestBody` builders (normalized by createResponse/createOperation) Also fix the README Refs example, which referenced helpers that never existed (`buildRefMap`/`resolveRef`); it now documents `extractRefName`. BREAKING CHANGE: the listed exports are no longer part of @kubb/ast. https://claude.ai/code/session_01UHmX1Z5cshiSKjzPoExazB
🦋 Changeset detectedLatest commit: ad3182b The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Following the public-API trim, remove the remaining exports that are unused across both this monorepo and the plugins repo. Each keeps its internal callers and test coverage; it just leaves the public surface. - isScalarPrimitive, resolveRefName, collectReferencedSchemaNames - isSchemaEqual (use schemaSignature equality) - isInputNode / isOutputNode - mergeAdjacentObjects (use mergeAdjacentObjectsLazy) BREAKING CHANGE: the listed exports are no longer part of @kubb/ast. https://claude.ai/code/session_01UHmX1Z5cshiSKjzPoExazB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improvements to
@kubb/astfor performance, ease of use, and lower complexity, informed by the patterns in Babel (@babel/traverse/@babel/types), the TypeScript factory, and the oxc toolchain in this repo. Crucially, the public-API trim is backed by real usage data: I measured every@kubb/astexport against both this monorepo and the plugins repo (kubb-labs/plugins, which consumes ast via@kubb/core'sexport * as ast).Changes
1.
@kubb/ast/typessubpath now exists (ease of use)The README's
import type { Node } from '@kubb/ast/types'previously failed — the subpath was never in the packageexports. Added atypestsdown entry (exports: trueregenerates the map). Mirrors@babel/types. ESM + CJS resolution verified.2.
walk()is genuinely concurrent (performance)walk()advertised aconcurrencylimit (default 30) and "siblings run concurrently", but awaited each child one at a time, so the option was inert and async visitors ran serially. Siblings now traverse viaPromise.allgated by the shared limiter. Added a test asserting real parallelism (the old test only checked the upper bound, which a serial impl passes trivially).3. Trimmed the public API surface (complexity) — breaking
Removed only exports unused across both repos that also duplicate/back a public counterpart:
nodeKinds,mediaTypesRefMaptypeInferSchematypeInferSchemaNodecollectLazycollectcreateContent,createRequestBodycreateResponse/createOperationAlso fixed the README
Refsexample, which referenced helpers that never existed (buildRefMap/resolveRef) — now documentsextractRefName.Verified: ast typecheck + 303 tests pass;
@kubb/core,@kubb/adapter-oas,@kubb/parser-ts,@kubb/renderer-jsxall typecheck against the trimmed package; oxlint + oxfmt clean. Major changeset included.Further trim candidates — left for your call
These are also unused across both repos, but they're plausibly-intended public utilities rather than clear dead code, so I did not remove them. Say the word and I'll trim any subset:
isScalarPrimitive,resolveRefName,collectReferencedSchemaNames,isSchemaEqual— standalone utilities (no public alternative)isInputNode/isOutputNode— kept for guard-set symmetry with the usedisOperationNode/isSchemaNodemergeAdjacentObjects(eager) — twin of the usedmergeAdjacentObjectsLazy, but it has its own test coverageRoadmap (not in this PR)
signature.ts— the 9-kindShapeField/SHAPE_KEYStable machinery is the package's heaviest abstraction; could collapse to direct per-type descriptor builders (medium risk — drives dedupe; needs test expansion first).utils.ts(956 LOC) — mixes ref-graph, import/export combining, and operation-param building; a pure file split would improve navigability.combineImports/combineExports— share a sort→merge→dedup skeleton that could be extracted.createLimitduplicatesp-limit(already a catalog dep).Notes
dist/is gitignored; onlysrc, configs, README, and changesets are committed.https://claude.ai/code/session_01UHmX1Z5cshiSKjzPoExazB