nodejs icon indicating copy to clipboard operation
nodejs copied to clipboard

Optimize client-side @commercetools/sdk-auth

Open maslowivan opened this issue 5 years ago • 1 comments

Description

A lot of useless code coming with this library:

  1. Buffer polyfill
  2. Lodash (defaultsDeep)

Expected Behavior

It works without these libraries or load them only on demand.

Current Behavior

It works with these libraries and is impossible even to replace them if you use just simple import SdkAuth, { TokenProvider } from '@commercetools/sdk-auth'; because it uses the UMD version.

Possible Solution

https://github.com/commercetools/nodejs/pull/1649 https://github.com/commercetools/nodejs/pull/1650 https://github.com/commercetools/nodejs/pull/1651

maslowivan avatar Jan 26 '21 15:01 maslowivan

+1 This prevents this library from being used with build tools such as Vite - which inherently don't support node polyfills in the browser - which subseqeuntly spits out ReferenceError: Buffer is not defined for any node related modules

tayzlor avatar May 13 '21 09:05 tayzlor