nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 229 forks source link

Remove requirement for bundler custom config #489

Closed bergos closed 2 years ago

bergos commented 2 years ago

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.

mcollina commented 2 years ago

@ShogunPanda could you review?

ShogunPanda commented 2 years ago

LGTM, if you could address https://github.com/nodejs/readable-stream/pull/489#discussion_r973996637 it would be great.