-
Notifications
You must be signed in to change notification settings - Fork 231
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/remove node globals - rebased & fixing IE issue #454
Fix/remove node globals - rebased & fixing IE issue #454
Conversation
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.
I think that this approach guarantees that most folks will have more than one nextTick shim in their bundle, which will inflate bundle sizes far more than just fixing webpack 5’s broken behavior.
I don’t understand why any change is being made here when webpack 5’s choice was to force users to deal with this. I also don’t see how it’s sustainable to try to force every package in the ecosystem to make similar changes, nor why this will be a benefit to the ecosystem to now have dozens of duplicate shims that are impossible to deduce (because they’re all potentially subtly different).
'use strict'; | ||
|
||
module.exports = function (cb) { | ||
var args = new Array(arguments.length - 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.
it’s very slow to use new Array; why is this not slicing arguments into an array?
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.
Indeed. I updated it for performance and push-rebased: https://github.com/nodejs/readable-stream/pull/454/files#diff-773895e366710aaad05c2daf697abc214727c9de1227114b5694878bd33322b2
whoops, sorry, didn’t mean to make it be a red X
ad57263
to
3331c2c
Compare
Hmm, would it be okay to use/require |
I think that anything that's in node itself shouldn't be provided, and that it is the exclusive job of a node module bundler to provide shims for node builtins in the browser. In other words, this package can and should do whatever's needed to support the desired node versions, only. If webpack 5 has abdicated part of its only job, that shouldn't impose a cost on the entire javascript ecosystem (not just the part using webpack 5). |
Webpack already did and the cost was already imposed. Now maintainers have two choices:
Given we already have a volunteer PR for #2 and Martin spent the work picking up the slack - why not take this code? |
@benjamingr because webpack users - 5 or otherwise- aren’t the only, or the most important, set of users in the ecosystem. This PR imposes a cost to everyone (or potentially ever other bundler user, depending on how it’s authored), and that is not a reasonable thing to inflict. Don’t forget about option 3 - we can hold the line, and webpack 5 may eventually fix its mistakes. |
I was actually trying to suggest option 4: use the cross-platform |
@martinheidegger I raised that idea earlier and @mcollina responded:
Can we try to prove that statement and then think about solutions? Because in packages where node builtins can safely be replaced with browser builtins, Webpack's change can indeed have a positive impact. That is not the case here - as far as we know now. Shims are a trap because they provide a better (build) user experience at first but hurt in the long run (1, 2, 3, 4). So I prefer to hold the line while we do explore long-term alternatives. For example, one difference between node's |
Note that a viable strategy to support webpack 5 is to simply link to instructions of how to use ProvidePlugin to effectively revert webpack 5’s harmful change. |
I agree with you, updating this is too much of a mess. |
Rebased version of #435 with patch to fix IE.