The current code requires adding custom configs for bundlers to import Node.js polyfills. This PR removes that requirement.
Polyfills are required directly in the code. This can be done because the Node.js core modules have the same names (buffer, events, process), and therefore, the code modules are used under Node.js. The polyfills are only imported for browser builds.
This required switching from buffer-es6 to buffer, and process-es6 to process. Both packages are more up-to-date than the ones that have been replaced.
Many lines have been touched, but the lib folder changes are pretty small. Most changes are related to the test code. The same imports are required, but more files are affected.
Besides the globals buffer and process, events is added as a dependency. No code changes are required in that regard because events is not accessible as global, and therefore, require calls are already in the current code.
The current code requires adding custom configs for bundlers to import Node.js polyfills. This PR removes that requirement.
Polyfills are required directly in the code. This can be done because the Node.js core modules have the same names (
buffer
,events
,process
), and therefore, the code modules are used under Node.js. The polyfills are only imported for browser builds.This required switching from
buffer-es6
tobuffer
, andprocess-es6
toprocess
. Both packages are more up-to-date than the ones that have been replaced.Many lines have been touched, but the
lib
folder changes are pretty small. Most changes are related to the test code. The same imports are required, but more files are affected.Besides the globals
buffer
andprocess
,events
is added as a dependency. No code changes are required in that regard becauseevents
is not accessible as global, and therefore,require
calls are already in the current code.