stripe / stripe-react-native

React Native library for Stripe.
https://stripe.dev/stripe-react-native
MIT License
1.29k stars 264 forks source link

Big size of Pod Dependencies for AppClip - any way to reduce it? #947

Open dawidzawada opened 2 years ago

dawidzawada commented 2 years ago

Is your feature request related to a problem? Please describe. I'm developing an App with shared code for AppClip - I need payments in both app versions. Unfortunately size of stripe-react-native Pod Dependencies exceeds 6MB. Apple AppClip's size limit is 10MB, my app current size is around 12MB with stripe-react-native package added. Is there's any way with a current package version to reduce size of the Pods? During installation of the pods I've noticed that i'm downloading quite a few packages:

pod install

Installing Stripe (21.12.0)
Installing StripeApplePay (21.12.0)
Installing StripeCore (21.12.0)
Installing StripeUICore (21.12.0)
Installing stripe-react-native (0.3.0) 

I'm wondering if i need all of the stripe's Pods - my project is using only these imports:

import { useApplePay, useStripe, useGooglePay } from '@stripe/stripe-react-native';
import { StripeProvider } from '@stripe/stripe-react-native';
import { CardFieldInput, initPaymentSheet, presentPaymentSheet } from '@stripe/stripe-react-native';

Describe the solution you'd like For now, just some "hacky" way to reduce the stripe pods size, a future solution - way to use a part of big Stripe native code, for example - importing with manual linking.

charliecruzan-stripe commented 2 years ago

Hi! Yes, this is a great ask. It's in our roadmap to explore this- it's possible that what this would mean is separating out stripe-react-native into a couple of smaller, modular libraries.

dawidzawada commented 2 years ago

Is there any way to achieve something like that now? I would like to have shared payments code with my main app on my appclip but Stripe pods are too big to fit in Apple 10 MB size limit. I was also considering moving app clips's payment code to some separated website - and embedding it inside the app with the webview - but that’s more radical way to fix this size issue.

charliecruzan-stripe commented 2 years ago

Hm, you could manually go in and edit the native code and dependencies, but that would be pretty rough imo, and not all of the native libraries are split out yet.

I was also considering moving app clips's payment code to some separated website - and embedding it inside the app with the webview - but that’s more radical way to fix this size issue.

Honestly, for the time being, this might not be a bad idea if you're using something like payment links

tux2nicolae commented 2 years ago

Hi, right now I'm facing the same problem, unfortunately stripe-react-native is way too big for us. This is a very interesting concern because it defeats the app clip idea of doing something fast and pay for the services with apple pay, like for parking, renting a bike, pay for food.

Do you have any workarounds that we may use before separating the library in multiple modules.

Edit: From my tests there is ~6,6MB extra added to our app clip when using stripe-react-native

dawidzawada commented 2 years ago

I'm still in the research phase of using stripe payment logic inside of an app - separating is a really radical way for us. I'm after deleting quite a lot pods - our appclip size was over 12 MB - I've found this library - https://github.com/ivanmoskalev/react-native-compressed-jsbundle/ - and that is a really big step forward. Basically, this lib is compressing jsbundle of react native app. It might be helpfull in your case too. These are compression results:

Original size: 2684.33 KB
Compressed size: 449.661 KB

With that we've got closer to fitting the appclip size limit - the size after compression was over 10MB - right now the goal is to gain around 1MB - some pods need to be added, unfortunately.

aaronfisher commented 2 years ago

Hi, right now I'm facing the same problem, unfortunately stripe-react-native is way too big for us. This is a very interesting concern because it defeats the app clip idea of doing something fast and pay for the services with apple pay, like for parking, renting a bike, pay for food.

Do you have any workarounds that we may use before separating the library in multiple modules.

Edit:

From my tests there is ~6,6MB extra added to our app clip when using stripe-react-native

Hello. Did you happen to find a solution that works for you?

aaronfisher commented 2 years ago

Bumping this up :)

Is there a timeline for splitting up the sdk in react native?

tux2nicolae commented 2 years ago

@aaronfisher unfortunately we didn't find a solution acceptable for us beside modifying this library, which is a little too much for us in development effort. Because of this we postponed the payment processing feature for a few months.

If you find a solution that works well for you (and if you can) please share it with us here.

charliecruzan-stripe commented 2 years ago

Timeline isn't set in stone yet, but planning has already started. What would be useful on this issue would be to match @dawidzawada 's original post and show what imports you use, so we can ensure that how we modularize meshes well with your expectations 😄

dawidzawada commented 2 years ago

what imports you use, so we can ensure that how we modularize meshes well with your expectations

Little update from my side. These are my current imports:

import { StripeProvider } from '@stripe/stripe-react-native';

import { useApplePay, useGooglePay, useStripe } from '@stripe/stripe-react-native';

import { initPaymentSheet, presentPaymentSheet } from '@stripe/stripe-react-native';

In my opinion, it would be really helpful for appclips & instant apps to split stripe package with smallest pods/packages possible. For example ApplePay, GooglePay, should have separated pods/packages - for iOS app clips only ApplePay would be imported. For android's instant apps - we would switch to GooglePay import. Also cards payment sheet should be separated, same goes with the rest of the stripe package. With that, even if some appclip is on the edge of the limit and for example it would use ApplePay & Cards Sheet - size would be easier to maintain, some functionalities could be dropped e.g. Cards might be removed but Apple Pay would be still available.

tux2nicolae commented 2 years ago

Do you have any updates on this?

maxrodrigo commented 2 years ago

@charliecruzan-stripe Any updates on this?

JeroenJochems commented 1 year ago

The iOS SDK has recently been split into modules. Can we expect this modularization in the react native SDK anywhere soon? This is a major blocker for using RN + stripe at the moment.

tux2nicolae commented 1 year ago

@dawidzawada did you manage to find a solution on this?

tux2nicolae commented 1 year ago

It's even worse now than when this issue was created.

Just tried again with the latest version and and our app clip increases in size to 18,4 MB uncompressed from 9,6 MB uncompressed an addition of 8,8 MB, this seems unreal, how does this library get to 8,8 MB when we have an entire app fit in 9,6 MB including react native framework, navigation, notifications, animations, localization, camera, permissions, UI library (react-native-paper), icons, and a few more.

charliecruzan-stripe commented 1 year ago

Yes, now that the iOS SDK has been split into modules, we are unblocked to start this work. We don't have a defined date yet, but as soon as we do I'll update here

martimarkov commented 1 year ago

It's been a few months now, I get that you might not have a definitive timeline but there must be some sort of a roadmap we can expect from the react-native SDK, otherwise it's not a complete product vs the other SDKs being offered by stripe

tux2nicolae commented 1 year ago

Indeed, unfortunately I given up on using stripe in the app clip, we still are using it in the main app, and would be nice if we could have the same implementation and be able to use it.

martimarkov commented 1 year ago

I’m looking into Adyen as an alternative and will post my findings here. It might have a smaller footprint which would be very useful for the main app as well.

The lack of support from Stripe on their official React-Native SDK is a bit much. It feels like a second class citizen in their offering.

charliecruzan-stripe commented 1 year ago

Sorry folks, I understand that this is an important change to make but we unfortunately just haven't been able to prioritize it recently. My hope is that we will be able to give you a more definitive timeline soon. It is on our radar and I'm aware how important this is

edit: woops! didn't mean to close the issue, re-opening

tux2nicolae commented 1 year ago

Related Stackoverflow question

https://stackoverflow.com/questions/77158898/app-clip-and-instant-app-with-stripe-payments-using-react-native

RobertSasak commented 1 year ago

Ad: I have created an early version of a wrapper for StripeApplePay. https://github.com/RobertSasak/react-native-stripe-apple-pay With this post I am looking for contributors.

For motivation here is how my app size reduced.

+App size: 6,4 MB compressed, 17 MB uncompressed
+Bundle is 3.13 MB
-App size: 2,6 MB compressed, 8,2 MB uncompressed
-Bundle is 3.08 MB
Fannolo commented 10 months ago

Hello there everyone, is there any updates on this just to know if it's still a thing that needs to be developed

Timeline isn't set in stone yet, but planning has already started. What would be useful on this issue would be to match @dawidzawada 's original post and show what imports you use, so we can ensure that how we modularize meshes well with your expectations 😄

is there any update over this?

tux2nicolae commented 9 months ago

Are there any updates on this? We are waiting for more than I year on this issue :(

TahaKhanAbdalli commented 6 months ago

Any updates on that @charliecruzan-stripe?

devloe commented 5 months ago

Any updates?

tux2nicolae commented 4 months ago

@RobertSasak thank you for the https://github.com/RobertSasak/react-native-stripe-apple-pay awesome library, really useful!

Do you know any alternatives for android too? We have an instant app on android as well and can't afford this library full size.

RobertSasak commented 4 months ago

@tux2nicolae On Android we use @stripe/stripe-react-native as it is not so huge.