Skip to content

perf(build): bundle to a single minified file (tsup) — v1.81.0, ~66kB → ~41kB - #177

Merged
justadev-afk merged 1 commit into
masterfrom
feat/shrink-bundle-1.81.0
Jun 10, 2026
Merged

perf(build): bundle to a single minified file (tsup) — v1.81.0, ~66kB → ~41kB#177
justadev-afk merged 1 commit into
masterfrom
feat/shrink-bundle-1.81.0

Conversation

@justadev-afk

@justadev-afk justadev-afk commented Jun 10, 2026

Copy link
Copy Markdown
Owner

What & why

twisted is a thin API wrapper, so the published artifact should be small. This PR replaces the multi‑file tsc output 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-queue is the only runtime dependency).

Changes

  • Bundle with tsupdist/ is now just index.js (minified CJS) + a rolled‑up index.d.ts. The TFT static JSON is inlined; promise-queue stays external.
  • target es6 → es2021async/await, ?. and ?? emit natively, removing the __awaiter/__generator helpers that were duplicated across ~20 files. (es2021, not es2022, to avoid flipping useDefineForClassFields.) Already require Node ≥ 18.
  • JS is minified, but the rolled‑up .d.ts keeps its JSDoc → smaller code, hover/IntelliSense docs preserved.
  • yarn build runs tsc --noEmit first so type errors still fail the build; added a typecheck script.
  • Stop publishing yarn.lock — useless to consumers, only bloats the tarball.

Expected bundle size

Packed (npm) Unpacked Files
1.80.x (current) ~66 kB ~311 kB 349
1.81.0 (this PR) ~41 kB ~166 kB 5

dist/index.js41 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.

⚠️ Breaking change → minor bump 1.81.0

Deep imports such as twisted/dist/errors or twisted/dist/apis/... no longer resolve. Import from the package root instead — the barrel re‑exports apis, errors, Constants and Dto:

import { LolApi, Constants, GenericError } from 'twisted'

Verification

  • tsc --noEmit (typecheck) + tsup build ✅ · eslint ✅ · 42/42 jest tests
  • Runtime smoke against the built dist/index.js (Account → Summoner → Match‑V5 chain + TFT StaticFiles from the inlined JSON) ✅
  • Consumer type‑check against dist/index.d.ts (API classes, Constants values, method return types, error classes) ✅

Merging publishes 1.81.0 to npm via the (now resilient) Deploy workflow.

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>
@justadev-afk justadev-afk changed the title Feat/shrink bundle 1.81.0 perf(build): bundle to a single minified file (tsup) — v1.81.0, ~66kB → ~41kB Jun 10, 2026
@justadev-afk
justadev-afk merged commit 1cc3263 into master Jun 10, 2026
6 checks passed
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