buffer icon indicating copy to clipboard operation
buffer copied to clipboard

Buffer 4.9.2 refers to `global` which is a node-only feature.

Open Arlen22 opened this issue 2 years ago • 1 comments
trafficstars

It seems that Buffer 4.9.2, which is explicitly a browser polyfill, tries to access a global variable, which as far as I can tell, is only available on Node. Why I haven't run into this before today I can't tell, but suddenly an Angular project I'm working on starting having trouble with this. It goes through the amazon-cognito-identity-js dependancy, which even in the latest version explicitly requires 4.9.2. I don't know why this suddenly happened, and I guess with 13 million downloads it probably isn't a bug, but I don't really know what's going on.

Arlen22 avatar May 22 '23 18:05 Arlen22

Yeah this seems ridiculous to me, surely

Buffer.TYPED_ARRAY_SUPPORT = global && global.TYPED_ARRAY_SUPPORT !== undefined
  ? global.TYPED_ARRAY_SUPPORT
  : typedArraySupport()

or

Buffer.TYPED_ARRAY_SUPPORT = window.TYPED_ARRAY_SUPPORT !== undefined
  ? global.TYPED_ARRAY_SUPPORT
  : typedArraySupport()

would make more sense here.

Amplify recommends using a polyfill of

window.global = window;

But this seems like adding fuel to the fire here.

lukemcgregor avatar Sep 26 '23 23:09 lukemcgregor