r/javascript • u/AsyncBanana • Apr 16 '21
Why you should not use Webpack
https://asyncbanana.medium.com/why-you-should-not-use-webpack-f07f4fd7c1162
u/shuckster Apr 16 '21
Snowpack uses esbuild and is worth mentioning separately.
It's seen a lot of development recently. It can be used without config from the CLI, but it's pretty easy to configure too.
EDIT - I should also say, congratulations on the article!
1
u/AsyncBanana Apr 17 '21
Thanks! The reason I left out esbuild is that it does not have a built in dev server, although I could note that it would include the dev server plugin if I do include it
1
10
u/OolongHell Apr 17 '21
The article does not bring the value it promises in the headline. I've learned that webpack is slower, that you find it complicated and that it generates larger bundles. The question remains, why should I avoid using it?
Besides, some facts there are not true. Webpack does not necessarily have to compile all bundles on start, it depends on the configuration.
3
u/minato3421 Apr 17 '21
Same question. Why should I avoid it? The article hasn't provided enough justification for me not to use webpack
1
u/AsyncBanana Apr 17 '21
In response to some of the comments, yes, lots of the alternatives (except for Rollup) are not very mature, but I still think that new projects should at least consider the alternatives.
4
u/Capaj Apr 17 '21
We'we migrated a big react.js project(200k LOC plus) from webpack to vite.js in the past month. It uses tons of custom stuff like multiple entry points and multiple index.html pages, babel macros, less files, graphql, whatever. We need to target IE11, so the bundle must be ES5 compatible.It does have a few small warts, but so far it's been good. Builds are faster and HMR is instant. Startup is always under 2 seconds, inital load in the browser is around 10 seconds, versus webpack where it took 35 for the initial bundling.We had to modify their official plugins just a tiny bit, for example here, but the whole thing is so much easier to configure and maintain than webpack. Once a small community forms around vite.js, it's going to obliterate webpack.
5
u/acemarke Apr 17 '21
I would be very interested in reading an extensive technical blog post on this!
3
u/Direct_Swordfish_735 Apr 19 '21
I didn't endure so many wtf moments when learning webpack to just abandon it.
-3
14
u/dgreensp Apr 17 '21
Eh, I tried not to use webpack, in my personal projects, for almost a year, and ended up going back to it.
I’ve tried Parcel and Snowpack, and used each until I felt forced to switch away. One of my theoretical beefs with Webpack has always been that it feels inscrutable, like I know internally it watches files and builds a module graph and runs a pipeline of plugins and stuff, but I don’t really have a good mental model of what it’s doing. Well, tools like Parcel and Snowpack are just as inscrutable, but less capable and buggier. Parcel wrote their own file-watching library, which had bugs, which they were slow to fix because they were working on a total rewrite of the whole thing, which took a long time. They also were focused a lot on “magic” like installing npm modules for you, which caused problems for my project setup and wasn’t something that could be fully turned off. They put a lot of energy into making certain core languages and technologies “just work.” But there’s sort of a long tail of things you might want from your bundler. Webpack supports doing whatever you want, with a lot of plugins available, and you can write your own. While it is complicated, there is documentation, and it can be figured out. With something like Snowpack, if you want to run transformation X on your code, you might find there is no plug-in for it, and no documentation that suggests any way it could be possible. Webpack is a bundler, not some magic development environment, and not an “un-bundler” like Snowpack. I would be excited about something like Webpack but a little easier to wrap my mind around, that was powerful and had good documentation.