-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
build: minify undici #53870
base: main
Are you sure you want to change the base?
build: minify undici #53870
Conversation
Review requested:
|
I’m strongly -1 with this. I regularly have to debug Node.js JS layer. Minified JS almost means obfuscated JS. And I’m not sure about executing npx with an extra dependency. Not a fan of this change |
@juanarbol Doesn't source maps fix that? |
what are the numbers? how much does this improve the binary size? |
It is not about that only. When code is obfuscated, it could impact performance as well. V8 is a capricious engine. This is not a lib for a CDN, having a bit more of extra bytes is not that critical (only for distributions, no in runtime). And it the thing about about bundle size; that means we will have to distribute the source maps for the debugging.
Not sure if that will actually have impact, everything in JS will go thru' the js2c task. Again, not the biggest fan of this, it introduces npx with a lib, not sure that is reliable, the "compressed" js output will require fixing the "esbuild" version, I mean; something else to maintain. And I don't see any factual value on this. Still -1 on this, but maybe people from @nodejs/build could give a more objective opinion about this. |
@Kikobeats And congrats on the first contribution! Sorry for being that strict! You want to land something on a big project, we just needs to ensure we delivers the best -always-. Thanks for taking the time to contribute! |
CC @nodejs/undici |
I'm +1 if it's backed with data (benchmarks) |
I am -1 |
I think the correct way to implement this is through having a build option called minify-js which only minifies when building for release. |
Afaik undici already goes through a build step, idk if location are preserved |
I agree, because in my opinion, if minification were to occur, it should happen during build, allowing the debug build to retain the unminified sources. |
I'm skeptical of the usefulness of this. -1 |
-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I doubt this will land due to the previous -1s, this currently will break class names and the node
/undici
user-agent header detection. It also doesn't lock esbuild to a specific version.
https://github.com/nodejs/undici/blob/d61af698dc50234289621c3613be9a8e42bf8e1f/package.json#L65
Without bundling, the deps-specific require that's used internally also won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
I find very little, if any, value in this.
- minification occasionally leads to behaviour changes which we wouldn't catch
- stack traces provided by users in issues would be useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 hi Kiko 😄
Unfortunately I don't believe we can support this. You can always supply your own, minified/optimized version of Undici and set it as the global dispatcher. May have a similar outcome.
After a meeting yesterday this PR is shining in a different light. It is about startup time of a node instance. Using a dispatcher is not the solution. What if we use esbuild as a bundler and not as minifier. Maybe removing comments. This should improve the hoisting. Is that improving the startup performance significantly? |
I wonder if resource mappings can be used to resolve this? example: find "deps/undici/src" -type f -name "*.js" | while read -r file; do
npx esbuild "$file" --minify --sourcemap --outfile="$file" --allow-overwrite
done |
This is what we're already doing? |
@KhafraDev and I already faced this previously for some optimization attempts. I believe we are bundling already. There are more esbuild optimizations we could try (such as comment removal iirc), but there are nuances to investigate carefully. |
Hi, I noticed that undici is not minified (none of the dependencies actually?).
It's big enough to be worth compressing to save half the space, but also to make it faster when it's required, not just using a normal require, also because undici contains lazy requires that are performed during the first fetch.
I know this is missing benchmarks, but wanted to hear what you think before continuing 🙂