-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: grammy/web builds for all plugins and storage adapters #372
Comments
This is generally the case with all plugins. The core repository is the only project that has a web build. We need to add a similar setup to all ~30 repos. Contributions are very welcome! |
@KnorpelSenf did you have any branch, where you implemented the feature for the core rep? |
grammY is natively written for Deno. Deno code is compatible with the browser and cloudflare. That's why a simple The only problem used to be that cloudflare didn't support top-level await. (This was added by now.) This is why we sort of always had web builds, so it wasn't really an isolated feature we added at some point. The tooling to create these JavaScript bundles has evolved over time. I think the most useful PQ to check is #339 which takes the existing web bundle and adds it to the npm package in order for it to be consumed by wrangler. |
@dandaka are you interested in working on this? I'd be happy to review and assist. I'm sure @roziscoding will also be able to answer any questions :) |
I am a junior dev at best, learning React + Typescript + Node + modern JS at the same time while developing a pet project. So while I am interested, it might take a gigantic effort at my current level :) |
Ah I'm not worried about that. grammY is the right place to achieve great things no matter what your level of expertise is. There are many stories to tell of novice coders who grew far beyond themselves here, so if you'd like to give it a try, I'm fairly certain that you'll succeed :) |
I encountered a similar problem when deploying on Vercel Edge Runtime. If importing the grammY core for web is not a problem: import { Bot } from "grammy/web"; // instead of "grammy" The plugins will still use the default import: import { /*...*/ } from "grammy"; To solve this problem, I tried two methods:
The first option seems to be the most compatible, but it have an issue with TypeScript types import. At the moment, I have not found a way to fix this, and I do not have lot experience with TypeScript. As a result, for my projects, I decided to use the second method, in which the types imports correctly and all plugins that do not depend on built-in Node.js modules too. |
I have moved to Deno + Deno Deploy and never looked back! |
Well that's certainly the smart choice, but people will still need |
@KnorpelSenf Can you explain or give instructions on how it would be correct to implement |
I believe it'd be something similar to what's done for the core package |
Ideally, the solution looks like this:
I am not sure when to tackle this, but I find it hard to imagine that this is possible without step 2 because d2n requires a config file, and this config file is different per project. Unless we find an easy way to solve this (long CLI flags?), we need to move to a tool that requires no config. /cc @wojpawlik |
Overkill. Other packages already can
Good point @PonomareVlad. Entry point could provide |
I like that a lot. Can I ask you to procrastinate a little more and open a PQ? |
Closing in favour of #559 |
Now
All Storage Adapters (and Session as it is dependent on them) do not support working without Node API. So Grammy can't be used with the sessions plugin on Cloudflare Workers (and similar Edge platforms).
Expected
Some/all Storage Adapters can be imported without Node API dependency.
The text was updated successfully, but these errors were encountered: