Automattic / wp-api-console

WordPress (.com and .org) API Console written in React/Redux
GNU General Public License v2.0
70 stars 20 forks source link

Replace crypto with hash.js to avoid needing Node polyfills #90

Closed dmsnell closed 2 years ago

dmsnell commented 2 years ago

~Do not merge until after #89 is merged~

Previously babel included Node polyfills to ensure that libraries relying on them in the browser context would work.

However, this stopped happening in newer versions which means if we want to update babel we need to either manually add those polyfills or rely on packages that don't require them.

In this patch we're replacing our use of crypto with hash.js to remove one of those dependencies.

In the work exploring this change I also considered createHmac as a dependency but the overall impact on build size was smalled with hash.js and a selective import (which allows only including the HMAC function we use).