braintree / braintree_node

Braintree Node.js library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
334 stars 104 forks source link

Modules not resolved with adapter-cloudflare (crypto, stream, http, https, zlib) #227

Closed BattlefieldDuck closed 9 months ago

BattlefieldDuck commented 11 months ago

General information

Issue description

Cloudflare Pages doesn't fully support node, so the node lib like "crypto", and "stream" doesn't work on Cloudflare Pages. The braintree-node library using the node libraries causes the Cloudflare Pages fail to build.

Cloudflare Pages Build log

03:47:45.783 | node_modules/braintree/lib/braintree/digest.js:3:21: ERROR: Could not resolve "crypto"
03:47:45.783 | node_modules/braintree/lib/braintree/document_upload_gateway.js:6:23: ERROR: Could not resolve "stream"
03:47:45.784 | node_modules/braintree/lib/braintree/http.js:4:19: ERROR: Could not resolve "http"
03:47:45.784 | node_modules/braintree/lib/braintree/http.js:5:20: ERROR: Could not resolve "https"
03:47:45.784 | node_modules/braintree/lib/braintree/http.js:6:19: ERROR: Could not resolve "zlib"

There is a similar issue in the Stripe library too. https://github.com/sveltejs/kit/issues/3564 https://github.com/sveltejs/kit/issues/6547

and they solved it on this PR. https://github.com/stripe/stripe-node/pull/1679

Possible Solution

Move all platform-specific implementations into PlatformFunctions, like how stripe fixes that issue on that PR.

hollabaq86 commented 9 months ago

👋 @BattlefieldDuck thanks for reaching out and providing this feedback. We're going to take this and discuss internally whether support for platforms that don't support Node APIs directly is something we want to add to the SDK. I don't have an ETA or yes/no decision for you, but we have received your feedback!