r/javascript • u/sindresorhus • Oct 11 '20
Webpack 5 Headache
https://blog.sindresorhus.com/webpack-5-headache-b6ac24973bf112
Oct 11 '20
At the end it sounds like the author wishes Node to be more like Deno, yet he's blaming Webpack for going the same direction (being: relying on Web APIs rather than Node ones).
He also complains browsers should have a utility like promisify, which makes no sense to me at all. The only reason that's useful at all is because Node has those horribly callback-style APIs where error objects are passed as the first argument to callbacks. Other environments don't have such APIs thus wouldn't really benefit from having it.
Ultimately it's just a rant different environments are different. If you want to unify, there's going to be friction, which will be the case with the new Webpack. But wishing everyone supports all APIs forever is not a realistic alternative, no matter how unfortunate that is sometimes.
5
u/sindresorhus Oct 11 '20
At the end it sounds like the author wishes Node to be more like Deno, yet he's blaming Webpack for going the same direction (being: relying on Web APIs rather than Node ones).
While I do wish Node.js was closer to Deno, your conclusion is not what I intended. I'm blaming Webpack for removing an existing feature that users depended on with very little guidance on how to deal with it and with the expectation that package maintainers should take on the burden instead.
He also complains browsers should have a utility like promisify, which makes no sense to me at all. The only reason that's useful at all is because Node has those horribly callback-style APIs where error objects are passed as the first argument to callbacks. Other environments don't have such APIs thus wouldn't really benefit from having it.
Browsers have more callback APIs than promise APIs. The difference is that many of these don't have an error argument. But that could be dealt with by providing an option indicating whether there's an error argument. I have done so in my own promisify package (created long before
util.promisify).Ultimately it's just a rant different environments are different.
No, it's a rant on how Webpack is meant to simplify front-end tooling, but in the end, makes it even harder for users.
6
u/alleycat5 Oct 11 '20
While I do wish Node.js was closer to Deno, your conclusion is not what I intended. I'm blaming Webpack for removing an existing feature that users depended on with very little guidance on how to deal with it and with the expectation that package maintainers should take on the burden instead.
And to pull another quote from your article:
Honestly, Webpack not polyfilling does make sense in theory. I just think they did it too early and with too little consideration about its effects on the ecosystem.
To be frank, that's a terrible reason to knock them for this. You as much as anyone should know the cost of compatibility features like this. And they've been communicating this change since beta.1 and loooong before and the reasoning has always been that users should not be depending on these polyfills. They're not expecting package maintainers to take the burden, they're trying to kill this long standing ecosystem hack. The only thing they ask mainainters to do is clearly communicate web browser compatible builds if any.
No, it's a rant on how Webpack is meant to simplify front-end tooling, but in the end, makes it even harder for users.
A whole big theme of this release is simplifying things for end users and unifying webpack's behavior with where the ecosystem has moved to. Preserving things like this is just shifting complexity onto the webpack authors and bloating bundles for what was ultimately always an ecosystem hack.
I won't entirely defend the Webpack authors here. They could have communicated the release, the gotchas, and the upgrade path better. But I do think it is entirely unfair to critize them for this.
1
u/sindresorhus Oct 11 '20
And they've been communicating this change since beta.1 and loooong before
For the majority, the Webpack 5 blog post is the first time they hear about it.
and the reasoning has always been that users should not be depending on these polyfills.
Maybe in a perfect world, but in reality, the result is just that users and package maintainers will have to deal with it instead. Users will now have to figure out how to manually add these polyfills.
3
u/alleycat5 Oct 11 '20
Users will now have to figure out how to manually add these polyfills.
Or drop the libs requiring them. Having watched this same story play out in other ecosystems, part of the point is get users to be aware of the problem and move away. Or just stick with Webpack 4 for as long as it's feasible.
0
u/sindresorhus Oct 11 '20
Yes, that's also a good solution, but switching to a different package takes some effort too.
2
u/alleycat5 Oct 11 '20
Agreed. Honestly, I expect 95% of users will just sit out the upgrade for a few months until projects like Next, Nuxt, and the rest catch up. That's what we're going to do. The blog post sort of says to do that, but I wish they'd said it in stronger terms.
-1
u/doodirock Oct 11 '20
You’re blaming them for not tracking the communication from the team? Wut.
3
u/alleycat5 Oct 11 '20
No, Sindre is right in that regard. A major blog post communicating the breaking changes months or years ago would have been welcome. Webpack is ubiquitous, expecting all its users (direct or indirect) to track the issue tracker isn't sensible.
0
u/doodirock Oct 11 '20
Agreed as well. I’m just not sure what else they should be doing. Open source revolves around a lot of unpaid hours. I think because of this time is better served contributing rather than throwing shade.
2
3
u/leodriesch Oct 11 '20
I don’t really see the problem. Can you name a few libraries commonly used in frontend development that will be affected? Cause I can’t think of one.
1
u/H-s-O Oct 12 '20
What the hell, that's like developing a Node native addon module and complaining that browser vendors are not willing to support it
0
Oct 11 '20
[deleted]
4
u/sindresorhus Oct 11 '20
I feel like I have been quite accommodating for Webpack users. I have added lots of workarounds (for example, for dynamic require warnings), refactored exports to work better, split up exports to be more tree-shakeable, answered Webpack support questions, and generally pointed folks in the right direction. However, I will not make packages worse for Node.js users in favor of Webpack user's needs.
23
u/arcanin 🧶 Yarn maintainer Oct 11 '20 edited Oct 11 '20
Just to be clear:
You're using Node builtins, which are intrinsically exclusive to Node
Then you complain that the Webpack team isn't willing to take responsibility for that
And to make it better, you decide to make a passive aggressive blog post to shame them, knowing full well how hard being an open source maintainer already is?
Webpack is a bundler. Their core mission has nothing to do with abstracting APIs across environments - that they did it in the first place was a nicety, and that you decided to rely on it is entirely on you (especially since not all bundlers had these polyfills by default). That they decided in a major they didn't have the bandwidth to support this usage in the core anymore is perfectly fine - you had literally years to do something about it, it's not like Webpack 5's development was in submarine for anyone.
Perhaps you should consider that Webpack 1 to 4 made their software worse, for you, to give you time to adjust, and that you didn't. Don't take it on them once they tell you that hey, your packages aren't portable and it's costing them resources to support you, resources that would be better spent elsewhere.
[edit] Nice, Sindre blocked me on Twitter and GitHub for this comment.