braintree / braintree-web-drop-in

Braintree Drop-in for the web
MIT License
200 stars 126 forks source link

Can't walk dependency graph when building #699

Closed crackedeggs1 closed 3 years ago

crackedeggs1 commented 3 years ago

Trying to build a fork of this following the instructions fails for me everytime.

npm install
npm run build

The error message is always:

[18:31:27] 'build:js:notmin' errored after 412 ms
[18:31:27] Error: Can't walk dependency graph: Cannot find module 'braintree-web/client' from '/home/xxxxx/npm/node_modules/braintree-web-drop-in/src/index.js'
    required by /home/xxxxx/npm/node_modules/braintree-web-drop-in/src/index.js
    at /home/xxxxx/npm/node_modules/braintree-web-drop-in/node_modules/resolve/lib/async.js:137:35
    at processDirs (/home/xxxxx/npm/node_modules/braintree-web-drop-in/node_modules/resolve/lib/async.js:290:39)
    at isdir (/home/xxxxx/npm/node_modules/braintree-web-drop-in/node_modules/resolve/lib/async.js:297:32)
    at /home/xxxxx/npm/node_modules/braintree-web-drop-in/node_modules/resolve/lib/async.js:25:69
    at FSReqCallback.oncomplete (fs.js:183:21)
    at FSReqCallback.callbackTrampoline (internal/async_hooks.js:131:14)
[18:31:27] 'build' errored after 434 ms

The error goes on to say there might be more information in a log file, but if anything, the log contains even less information.

If I modify braintree-web/src/client/client.js so that there is a syntax error, then the build fails with a syntax error, so I know that the build process is locating and reading the file. So it seems like this error is a complete falsehood.

I have tried having braintree-web under braintree-web-drop-in/node_modules (per default npm install results), as well as at the same level as braintree-web-drop-in. It seems that braintree-web mostly builds successfully if done on its own (although fails at the step where it tries to "publishing" the build and I don't see where to turn that off).

I'm not sure how to get past this. I've been stuck on this for 3 days now just repeating the same "fixes" from StackOverflow over and over again to no avail. Already blew past the deadline for this project. We may have to abandon BrainTree for our carts if we can't get this working in the next 12 hours or so.

crookedneighbor commented 3 years ago

I just cloned down a fresh copy and had no issues:

git clone git@github.com:braintree/braintree-web-drop-in.git
cd braintree-web-drop-in
npm install
npm run build

My guess here, since you said you modified braintree-web/src/client/client.js is that you're trying to use a local version of the braintree-web sdk as well, rather than the one on npm, but a key difference in the version that gets published on npm and the version found on github is that it goes through a build process to remove the src directory and puts all the components at the top level. See https://github.com/braintree/braintree-web/blob/0729410e2a2d4e5a3fe07a6b127364a0fad0231a/tasks/build.js#L85-L95

crackedeggs1 commented 3 years ago

That explains why it only "worked" when I copied the -web/src files up one level. However, I thought this was the incorrect approach, because the resulting dropin files did not appear to have been browserified (still had references to npm.env, etc).

I guess it would be good to know then, what is the appropriate process when both braintree-web-drop-in and braintree-web need to be built from local versions?

crackedeggs1 commented 3 years ago

Anyway, thank you for the hint. I was able to successfully build braintree-web at least, knowing that I had to do that first. It was not building because for some reason ./publishing/.gitignore was missing from the fork. Once I manually copied that file from here, it finished.

Then symlinking the deep /dist location at braintree-web-drop-in/node_models/braintree, I was able to get past the original error.

You may want to add a doc section about what to do when building both. I thought it would just walk through like it does for all the other dependencies.

By the way, the main reason I had to build braintree-web/ was to tone down the activity of ./lib/analytics. In one cart transaction, I was seeing 100s to 1000s of XHR requests just for what seemed like debug logging. There should be a built in way to disable logging or to redirect it somewhere local.

crookedneighbor commented 3 years ago

100s-1000s of analytics requests does not sound correct. Opening up the network tab on the demo page, and I see fewer than 20 analytics requests:

Screen Shot 2021-02-25 at 9 49 17 PM

I would reach out to our support team to figure out what is happening that would cause those erroneous analytics requests. That indicates to me that something is going very wrong with your integration. https://help.braintreepayments.com/

crackedeggs1 commented 3 years ago

There's about 20 just for braintree analytics (which I already removed by forking the sdk), but also roughly 20 more for each payment method accepted, which go to the servers for those methods. Some of the logs appear to be on a time interval, which could be how I got up to 1000 in development (you're 10% there!). It looks like the cardinal songbird (3d secure) logging requests only occur in sandbox mode, or at least the cardinalSDKConfig.logging option only works in production. Is it safe to assume the other platforms (google, paypal, etc) also stop logging when in production? I feel like it would reduce customer trust if they see all these background requests going on on a page where they are asked to enter credit card information.

crookedneighbor commented 3 years ago

Changing the braintree analytics library does not affect any of those 3rd party library analytics. In fact, it just makes it harder for our support team to help you with your integration.

IMO, anyone who is savvy enough to inspect the network requests for the analytics can also see that none of them send any sensitive information.