perf: replace json-schema-to-typescript with a built-in emitter (-12 MB install) - #1325
Draft
l2ysho wants to merge 1 commit into
Draft
perf: replace json-schema-to-typescript with a built-in emitter (-12 MB install)#1325l2ysho wants to merge 1 commit into
l2ysho wants to merge 1 commit into
Conversation
`json-schema-to-typescript` served one command, `actor generate-schema-types`, and dragged prettier, lodash and js-yaml into the install. Dropping just the formatting is not possible — v15 imports prettier at module top level — so it is replaced by a built-in emitter in src/lib/schema-to-typescript.ts. Output is byte-identical to the old library on every repo schema fixture. Full install drops from 55.61 MB to 43.55 MB (-21.7%). `stripTitles` is deleted: it existed only to stop the library hoisting named interfaces, and the new emitter ignores `title` entirely. Closes #1310 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #1310. Part of #1305.
json-schema-to-typescriptwas the largest single install-size lever in the CLI. It served one command —actor generate-schema-types— and dragged in prettier, lodash and js-yaml. Replaced bysrc/lib/schema-to-typescript.ts(~270 lines).Why a rewrite and not just dropping the formatting
json-schema-to-typescript@15imports prettier at module top level, soformat: falsestill ships all 9.5 MB. It's one dependency or zero.Zero was viable because every option at the old call site turned a feature off:
maxItems: -1disabled tuple expansion,$refOptionsdisabled all remote resolution, andstripTitles(75 lines) existed purely to stop the library hoisting named interfaces. The command used a fraction of a general-purpose compiler at full price.Install size
prettier, lodash, js-yaml and
@apidevtools/json-schema-ref-parserleave the production graph entirely.Behaviour
Output is byte-identical to the old library on every repo schema fixture, strict and non-strict.
stripTitlesdeleted — the new emitter ignorestitle, so it was a no-op.TS2411), and*/inside adescriptionterminating the generated JSDoc.propertiesalongsideallOf/anyOf/oneOfis now intersected in rather than silently dropped.my-store/my_store) get suffixed instead of emitting duplicate interfaces.Accepted costs
$refs render asunknown;minItems/additionalItemstuple expansion is dropped. No Apify schema uses either, and the single-declaration design — previously enforced bystripTitles— cannot express recursion.Follow-up
BANNER_COMMENTstill emits/* prettier-ignore-start */with no matching-end. Stale before this change, now doubly so; left alone as out of scope.🤖 Generated with Claude Code