-
Notifications
You must be signed in to change notification settings - Fork 187
Adding svix for webhook validation adds almost 1 MB to the JS bundle #1483
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
Comments
Looks like I could also use https://github.com/standard-webhooks/standard-webhooks/tree/main/libraries/javascript as a lightweight alternative. However, it expects different non-branded headers... Update: This works perfectly fine. // Map unbranded webhook headers to Svix headers
const svixHeaders = {
'webhook-id': request.headers.get('svix-id') as string,
'webhook-timestamp': request.headers.get('svix-timestamp') as string,
'webhook-signature': request.headers.get('svix-signature') as string,
} So, I'm now using the tiny |
Some work has already happened on this by a contributor in #1179. |
Unfortunately we've had to revert #1549 in v1.44.0, so re-opening this. If you're using v1.43.0 without build issues though, you're welcome to stay on that version to enjoy the smaller bundle size while we figure this out. |
I tried this again today because I was excited to see Clerk adding a The bundle size situation has improved, but it's still 200 KB larger compared to using standardwebhooks. |
@mlafeldt, great to hear about the improvement, but annoying that it's so large. @svix-lucho, do you have any idea what's causing this? |
Bump |
Hey,
I've recently started using Svix to handle Clerk webhooks. For this, I tried adding the svix JS package to my Astro project to validate webhook signatures. Unfortunately, this ended up doubling my project's bundle size from 1 MB to 2 MB. 😱
As a workaround, I copied the following code and added
@stablelib/base64
+fast-sha256
as dependencies:svix-webhooks/javascript/src/index.ts
Lines 803 to 939 in d0443bd
Surprisingly, this had almost no impact on the bundle size.
I'm no expert on ESM or bundling, but there seems to be a problem with the code's structure that prevents proper tree shaking.
This is especially concerning in a constrained environment like Cloudflare Workers/Pages, where bundle size is (even more) important.
(Happy to provide more info if needed.)
The text was updated successfully, but these errors were encountered: