Skip to content

Tree-shakeable for cloudflare worker #11

Description

@kevinsimper

Hi :)

Really cool library!

I was trying to use it with Cloudflare, but notice it includes a lot of dependencies even when you try to send just a message.

I see that the tsconfig is newest and that exports are defined in the package.json, maybe the 20 kb for gramio itself would be fine, but the 400 kb for the context is a lot for cloudflare worker considering :)

Not enough of a expert on tree-shaking to say why esbuild can not remove it.

$  npx esbuild send.ts --bundle --platform=node --format=esm --outfile=out.js --minify --analyze --tree-shaking=true

  out.js                                               464.7kb  100.0%
   ├ node_modules/@gramio/contexts/dist/index.js       408.3kb   87.9%
   ├ node_modules/gramio/dist/index.js                  20.1kb    4.3%
   ├ node_modules/@gramio/format/dist/index.js           9.7kb    2.1%
   ├ node_modules/@gramio/keyboards/dist/index.js        8.8kb    1.9%
   ├ node_modules/@gramio/files/dist/index.js            4.7kb    1.0%
   ├ node_modules/debug/src/browser.js                   2.5kb    0.5%
   ├ node_modules/debug/src/common.js                    2.0kb    0.4%
   ├ node_modules/debug/src/node.js                      2.0kb    0.4%
   ├ node_modules/middleware-io/lib/index.mjs            1.8kb    0.4%
   ├ node_modules/ms/index.js                            1.4kb    0.3%
   ├ node_modules/gramio/dist/utils-CV4fnsQV.js          891b     0.2%
   ├ node_modules/inspectable/lib/index.mjs              768b     0.2%
   ├ node_modules/@gramio/callback-data/dist/index.js    617b     0.1%
   ├ node_modules/debug/src/index.js                     139b     0.0%
   └ send.ts                                            114b     0.0%


  out.js  464.7kb
import { Bot } from "gramio";

const bot = new Bot(process.env.BOT_TOKEN!);

const chatId = 1;

const response = await bot.api.sendMessage({
  chat_id: chatId,
  text: "some text",
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions