Some checks failed
Tests / e2e (push) Blocked by required conditions
Tests / e2e-deno (push) Blocked by required conditions
Tests / test-deno (push) Successful in 1m53s
Tests / test-bun (push) Successful in 2m1s
Tests / test-node (node22) (push) Successful in 2m8s
Tests / test-node (node20) (push) Successful in 2m10s
Tests / test-node (node18) (push) Successful in 2m16s
Tests / test-web (chromium) (push) Successful in 2m18s
Tests / test-web (firefox) (push) Successful in 2m31s
Tests / lint (push) Has been cancelled
Build and deploy typedoc / build (push) Has been cancelled
Co-authored-by: Kamilla 'ova <me@kamillaova.dev> Co-authored-by: Alina Chebakova <chebakov05@gmail.com> Co-authored-by: Kravets <57632712+kravetsone@users.noreply.github.com> Co-authored-by: starkow <hello@starkow.dev> Co-authored-by: sireneva <150665887+sireneva@users.noreply.github.com>
994 B
994 B
Tree-shaking
Being a ESM-first library, mtcute supports tree-shaking out of the box.
This means that you can import only the parts of the library that you need, and the bundler will remove all the unused code.
Usage
To start using tree-shaking, there are a few things to keep in mind:
-
Do not use
TelegramClient
. UseBaseTelegramClient
instead, and import the needed methods.For example, instead of this:
import { TelegramClient } from '@mtcute/web' const tg = new TelegramClient({ ... }) await tg.sendText(...)
you should use this:
import { BaseTelegramClient } from '@mtcute/web' import { sendText } from '@mtcute/web/methods.js' const tg = new BaseTelegramClient({ ... }) await sendText(tg, ...)
-
TL serialization is currently not tree-shakeable, because it is done via a global map of constructors. There's no ETA on when (or whether at all) this will be changed, so there will be ~300 KB of non-shakeable code.