-
Notifications
You must be signed in to change notification settings - Fork 570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use readable-stream #1782
fix: use readable-stream #1782
Conversation
Could have impact when vendoring into node. Should probably use proper stream in that case... is there an easy fix for that? i.e. alias |
We should definitely not bundle readable-stream when preparing the code for core. |
What about this: diff --git a/package.json b/package.json
index a02ae10..222a235 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,8 @@
"docs"
],
"scripts": {
- "build:node": "npx esbuild@0.14.38 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js",
+ "build:node": "npx esbuild@0.15.15 index-fetch.js --bundle --external:readable-stream --platform=node --outfile=undici-fetch.js",
+ "postbuild:node": "sed -i 's/require(\"readable-stream\")/require(\"stream\")/g' undici-fetch.js",
"prebuild:wasm": "docker build -t llhttp_wasm_builder -f build/Dockerfile .",
"build:wasm": "node build/wasm.js --docker",
"lint": "standard | snazzy", |
Thank you! Applied. |
@mcollina wdyt? |
CI seems really unhappy with this change. |
@mcollina yea, assuming I managed to fix that, do you have any further objections? |
Not, it should have been like this from the beginning but we were stuck with a very old and legacy version of |
Isn't the fix simply to |
Codecov ReportBase: 90.27% // Head: 94.85% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1782 +/- ##
==========================================
+ Coverage 90.27% 94.85% +4.58%
==========================================
Files 58 39 -19
Lines 5182 2859 -2323
==========================================
- Hits 4678 2712 -1966
+ Misses 504 147 -357
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
I would prefer if you just used |
Why? |
|
@mcollina wdyt? |
Why did you want to do this change in the first place? |
Make sure we have the latest stream fixes even when not running latest version of Node. The same reason why readable-stream exists in the first place. |
This is a truth with modification. Only if/when you are running latest version of Node. Otherwise, the opposite should be true.
I think and hope that situation is no longer true.
Yea, I guess that is a problem.
Also true. |
also it uses abort-controller polyfill instead of using built in whenever available. and it too lacks things like i don't know but how compatible it is with built in
I mostly saw it as "just to bring it outside of nodejs" and was only mostly ment for browserify and webpack... all those legacy package never updated their own code after a while and those started to lack newer features such as async iterable |
For me. I want to have all the latest fixes and features from Node streams even when running LTS. I prefer using both undici and streams from npm instead of core for this reason. |
Would be nice if it only used the polyfills when required, i.e. running an older Node version than expected. |
@jimmywarting those sounds good improvements to do to |
So it seems to me like this could be a good idea but would require some more things from readable-streams:
Would peer dependencies help with the former 2? |
I'm not so keen at working on buffer and/or stream. i have a huge cross compatible code mindset, such as (async)Iterators + uint8array instead (and now web streams). also got a huge bundlephobia for large packages 😝 But you can go ahead and do that... I just recently did a config.js in one of my project that only exported the things i needed to work with such as: const config = {
ReadableStream: globalThis.ReadableStream,
WritableStream: globalThis.WritableStream,
TransformStream: globalThis.TransformStream,
Promise: globalThis.Promise,
DOMException: globalThis.DOMException,
Blob: globalThis.Blob,
File: globalThis.File
}
export default config and if developers wanted to they could override all those things before i even start using anything of it... import config from 'mod/config.js'
config[xyz] = zxy
import mod so if they needed to support older version then they could bring their own polyfill and the version they needed/wanted/or already had |
Co-authored-by: Michaël Zasso <targos@protonmail.com>
No description provided.