perf(build): bundle to a single minified file (tsup) — v1.81.0, ~66kB → ~41kB - #177
Merged
Conversation
Builds on the 1.80.1 dependency cleanup (now on master) with a much smaller published artifact: - dist/ is now a single minified `index.js` (CJS) + a rolled-up `index.d.ts`, down from ~349 files to 2. The TFT static JSON is inlined; promise-queue stays external. - target es6 -> es2021 so async/await, optional chaining and nullish coalescing emit natively (drops the inlined __awaiter/__generator helpers that were duplicated across files). es2021 (not es2022) avoids flipping useDefineForClassFields. Already require Node >= 18. - JS is minified; the rolled-up declarations keep their JSDoc so editor hover docs are preserved. - `yarn build` runs `tsc --noEmit` before tsup so type errors still fail the build; `typecheck` script added. - Stop publishing yarn.lock (useless to consumers, only bloats the tarball). Published tarball: ~66kb/349 files -> ~41kb/5 files. BREAKING: deep imports such as `twisted/dist/errors` or `twisted/dist/apis/...` no longer resolve — import from the package root (`twisted`), which re-exports apis, errors, Constants and Dto. Hence the minor bump to 1.81.0. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What & why
twistedis a thin API wrapper, so the published artifact should be small. This PR replaces the multi‑filetscoutput with a single minified bundle built by tsup, shrinking what consumers download and the file count dramatically.Builds on top of the 1.80.x dependency cleanup already on
master(axios/lodash/dotenv/http-status-codes/uuid removed —promise-queueis the only runtime dependency).Changes
dist/is now justindex.js(minified CJS) + a rolled‑upindex.d.ts. The TFT static JSON is inlined;promise-queuestays external.targetes6 → es2021 →async/await,?.and??emit natively, removing the__awaiter/__generatorhelpers that were duplicated across ~20 files. (es2021, not es2022, to avoid flippinguseDefineForClassFields.) Already require Node ≥ 18..d.tskeeps its JSDoc → smaller code, hover/IntelliSense docs preserved.yarn buildrunstsc --noEmitfirst so type errors still fail the build; added atypecheckscript.yarn.lock— useless to consumers, only bloats the tarball.Expected bundle size
1.80.x(current)1.81.0(this PR)dist/index.js≈ 41 kB minified (~13 kB gzipped);dist/index.d.ts≈ 110 kB (the bulk of the tarball — JSDoc kept on purpose for DX). Net: ~38% smaller download, 349 → 5 files.1.81.0Deep imports such as
twisted/dist/errorsortwisted/dist/apis/...no longer resolve. Import from the package root instead — the barrel re‑exportsapis,errors,ConstantsandDto:Verification
tsc --noEmit(typecheck) +tsupbuild ✅ ·eslint✅ · 42/42 jest tests ✅dist/index.js(Account → Summoner → Match‑V5 chain + TFTStaticFilesfrom the inlined JSON) ✅dist/index.d.ts(API classes,Constantsvalues, method return types, error classes) ✅Merging publishes
1.81.0to npm via the (now resilient) Deploy workflow.