Closed judsonlmoore closed 1 year ago
Hi @judsonlmoore! That is strange, Stripe is supposed to be lazy loaded so it only gets loaded if you use the Stripe plugin. However, I'm seeing the same thing so we'll investigate what's going on.
Thanks @rohitdatta if I can support at all, please let me know. I'll follow this ticket for updates.
In the mean time if you pin @formspree/react to version 2.2.5 you'll avoid this problem until we sort it out. See https://github.com/formspree/formspree-react/commits/main
Hi we have a version at @formspree/react@2.3.4-beta.2
that should correctly lazyload stripe. If you have a minute @judsonlmoore can you try it out to make sure stripe isn't loading?
2.3.3 was loading Stripe for me when unnecessary, and 2.3.4-beta.2 works correctly.
I can confirm that 2.2.5 resolved the issue. I don't see 2.3.4-beta.2 available in the list of public releases so assume that might be private and therefor I couldn't test with that one.
Since version 2.4.0 stripe should correctly lazy load. There is still a small (~6kb compressed) react shim in the bundle, but the main stripe library doesn't load unless a stripe publishable key is set when adding <FormspreeProvider>
.
I'll keep this issue open for a bit longer until we make our announcement about stripe support in Formspree React. Until then feedback welcome!
See our announcement here: https://formspree.io/blog/react-payments-stripe-elements/
@colevscode Did you guys change something? I'm using v2.4.1
and I noticed Stripe is bundled even though all I use is useForm
.
And I taken a look at the source code of useForm
and noticed it does import from Stripe, but it appears to be a normal import, not dynamic import.
@mwskwong yes as mentioned above:
Since version 2.4.0 stripe should correctly lazy load. There is still a small (~6kb compressed) react shim in the bundle, but the main stripe library doesn't load unless a stripe publishable key is set when adding
<FormspreeProvider>
.
Is this what you're seeing?
I am using the @formspree/react component in a project that is then somehow getting a bunch of stripe js in production. Locally, these files are not being injected. You can see this in production at https://bikefi.net.
For example:
https://js.stripe.com/v3
is being loaded, but there are 6 "stripe" items if you search the code in developer tools.In my project I am importing the component like this
import { useForm, ValidationError } from '@formspree/react'
Stripe is not configured as a plugin on my formspree account, either.
Any ideas?