Skip to content
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] New web bundle #318

Closed
wants to merge 9 commits into from
Closed

[FEAT] New web bundle #318

wants to merge 9 commits into from

Conversation

roziscoding
Copy link
Contributor

@roziscoding roziscoding commented Nov 22, 2022

New bundling script generates bundling/bundle folder which can be npm published creating @grammyjs/web.

The package.json for the new package is automatically generated from the current package.json to avoid version mismatches.

Tested with vite, but not with CF workers.

Co-authored-by: Wojciech Pawlik [email protected]

Co-authored-by: Wojciech Pawlik <[email protected]>
Copy link
Member

@KnorpelSenf KnorpelSenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we retain the README section about the CDN? We don't shut it down.
  2. Should the Netlify CDN config be changed to redirect to https://bundle.deno.dev?

@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2022

Codecov Report

Base: 36.93% // Head: 36.93% // No change to project coverage 👍

Coverage data is based on head (d05dbc0) compared to base (63ac43a).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #318   +/-   ##
=======================================
  Coverage   36.93%   36.93%           
=======================================
  Files          17       17           
  Lines        4364     4364           
  Branches      157      157           
=======================================
  Hits         1612     1612           
  Misses       2750     2750           
  Partials        2        2           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wojpawlik
Copy link
Contributor

Constantly rebuilding every release is a pain. Let's just not upload new versions to CDN.

@roziscoding
Copy link
Contributor Author

  1. Can we retain the README section about the CDN? We don't shut it down.
  2. Should the Netlify CDN config be changed to redirect to https://bundle.deno.dev?
  1. Sure. Should we say it's not the preferred way of doing this or something?
  2. I think that makes sense, but it requires 1 to explain the new URL format, right? Because we don't have separate bundles anymore

@KnorpelSenf
Copy link
Member

KnorpelSenf commented Nov 23, 2022

  1. Can we retain the README section about the CDN? We don't shut it down.
  2. Should the Netlify CDN config be changed to redirect to https://bundle.deno.dev?
  1. Sure. Should we say it's not the preferred way of doing this or something?
  2. I think that makes sense, but it requires 1 to explain the new URL format, right? Because we don't have separate bundles anymore
  1. Yes, that'd be great. Explain: Deno, Node, web through Deno, web through Node, web through CDN. I'm not sure how much of this ought to be in the README, we might as well create a new docs page for it. They should probably be mentioned in the README either way.
  2. I'd just rewrite all URLs to the equivalent bundling service. Perhaps we need a tiny script for this on Deno Deploy.

Constantly rebuilding every release is a pain. Let's just not upload new versions to CDN.

I'd remove the CDN entirely and just let bundle.deno.dev handle instead what the CDN used to do.

@wojpawlik
Copy link
Contributor

wojpawlik commented Nov 23, 2022

CDN is pointless now. It has the same code as @grammyjs/web, except it doesn't work in CFW.

@KnorpelSenf
Copy link
Member

And yet there's no good reason to break people's setups, is there? It is a one-time action to set it up and it will require zero maintenance.

@wojpawlik
Copy link
Contributor

Sure, feel free to set up a redirect. Documenting it would just cause unnecessary confusion tho.

.github/workflows/release.yml Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
set -eu

# Cloudflare Workers don't support top-level await
sed -i~ 's/^if (isDeno)/if (false)/' ../src/platform.deno.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this, mostly because regex on source is very ugly and hard to maintain. The whole point is to have one clean file per platform. If we want to support different platforms that require different platform-specific code, we should create a new file and cp our way through.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rewrite to prevent top level awaits?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we provide a new file platform.web.ts, we can write it w/o TLA, yes.

bundling/bundle-browser.sh Outdated Show resolved Hide resolved
cp ../LICENSE bundle/
cp ../README.md bundle/
shopt -s globstar
rm bundle/**/*.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to explicitly copy over the files we need, rather than copying over everything and then deleting some specific parts of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would, but glob patterns are very sketchy and I couldn't get cp to reproduce the existing folder structure but ignore js files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rsync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't used it before.
I'll look into it

@KnorpelSenf
Copy link
Member

I want to look into this in my holidays

rm bundle/**/*.js

echo "Bundling source"
deno bundle ../src/mod.ts bundle/out/mod.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… then there is https://deno.land/[email protected]/tools/bundler#bundling-for-the-web:

The output of deno bundle is intended for consumption in Deno and not for use in a web browser or other runtimes. That said, depending on the input it may work in other environments.

If you wish to bundle for the web, we recommend other solutions such as esbuild.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esbuild wasn't smart enough to omit if (false) when I last tired it. Unlike SWC used by deno bundle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (false) is a big hack that should be avoided anyway. Do you remember how we went from bash scripts to d2n? I'd like to make a similar move here, and end up using good tools rather than writing custom scripts.

@roziscoding
Copy link
Contributor Author

roziscoding commented Dec 27, 2022

Closing in favor of #338 and #339

@KnorpelSenf KnorpelSenf deleted the feature/new-web-bundle branch December 27, 2022 11:04
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.

None yet

4 participants