connect-sdk-js icon indicating copy to clipboard operation
connect-sdk-js copied to clipboard

Remove "crypto" import

Open verkaufer opened this issue 2 years ago • 0 comments

Summary

Webpack 5 stopped automatically polyfilling Node.js (src). Because we use the node.js crypto library in one area of the item builder, users trying to integrate the SDK with the webpack bundler will see this error:

webpack < 5 used to include polyfills for node.js core modules by default" error

Use cases

n/a

Proposed Solution

Remove the crypto import from our SDK. We're only using it to generate sectionIDs, and there's a note that section IDs aren't cryptographically random anyways.

We should replace the crypto call with a quick-and-dirty "generate alphanumeric string" function.

Is there a workaround to accomplish this today?

Users can target node in their webpack config or enable nodejs fallbacks.

Both workarounds lead to larger bundle sizes for users.

References & Prior Work

  • https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-nodejs-polyfills-removed

verkaufer avatar Jul 27 '22 22:07 verkaufer