Keep Webpack Fast: A Field Guide for Better Build Performance
slack.engineering
slack.engineering
The project is less than two months old, so Parcel might not be a good fit for you. But if it is, it's usually a drop-in replacement. Zero configuration. Just run it and go.
We're working hard to add the most requested features: source map support is coming very soon, for example. But if you can put up with a few rough edges, Parcel promises to give you a ~5x performance increase over webpack.
(We kick off multiple processes to do the actual bundling work, and we have an asset cache, which accounts for most of the speedups.)
If you'd like to participate or have any questions, hop on our Slack! https://slack.parceljs.org/ We have about 500 devs ready to help you out and chat with you (about anything, really).
Feel free to snag an issue and start working on it: https://github.com/parcel-bundler/parcel/issues?utf8=%E2%9C%... There's plenty of work to go around.
It's been really cool to see so many people pitching in. We recently had a Japanese contributor help get Parcel up and running for multi-language projects: https://qiita.com/zacky1972/items/0ce05454b67506edc634
Definitely going to take a look at the code and try this out soon.
The state of the art in such matters is Rust with its type system-assisted fearless concurrency; my favourite demonstration of how it can work is Rayon, where introducing data parallelism is typically as simple as replacing a .iter() with a .par_iter(). I’d love it if something like Rayon could be ported to Node, somehow.
(By virtue of being excellent at the low-level and having zero-cost abstractions, Rust actually ends up being a really good high-level language.)
In Node, if you want to process a zillion files in the same way, there are no good solutions. I recently needed to improve the performance of a manually-crafted, Node-centred build process; in Rust, it would have been a matter of: add Rayon, replace a .iter() with .par_iter() and we’re done—and what’s more, it’ll only flex its parallelism muscles where it’s worthwhile. But in Node it took a several hours of trouble (after research, I settled on using worker-farm to help) to produce a strictly inferior result.
Rayon: https://github.com/rayon-rs/rayon worker-farm: https://www.npmjs.com/package/worker-farm
Node's single threaded event loop works well for some use cases but makes it hard to parallelize build process.
I would absolutely use a module bundler developed in a better suited language and distributed on npm as a binary like flow.
Fastpack: https://github.com/fastpack/fastpack
The real problem with all these sorts of things is network effects. People aren’t going to use the Rust port of postcss unless the plugin they want to use works in it, and it can be conveniently tied into their existing toolchain, and—— and——
This is why we can’t have fast, efficient things.
I’m really looking forward to getting something of the pthread style in WebAssembly, because then, finally, blending the two should be easily feasible. You can already use things like Neon (https://www.neon-bindings.com) to write Node modules in Rust, but it’s not as easy as it should eventually be a few years down the track.
I've never used postcss, but I don't think this is strictly for all js build tools. There's libsass, written in C++. I've mentioned flow. I'm sure there are others.
I think you're right though that webassembly is going to be big for this kind of thing.
Shawn, half the articles about Webpack I see recently have these kinds of comments about Parcel. This goes beyond excitement into spammy behaviour. I've seen plenty of other people complaining about this too.
This was an article about Webpack performance, and you've come along to talk about unrelated Parcel features like source map support and i18n, to link to the Parcel Slack, and to ask for help working on Parcel bugs.
It really puts me off Parcel and there's no chance I'll look at it so long as when an article about Webpack pops up, there's always a comment from a Parcel developer spamming your project. Please stop spamming Parcel in Webpack discussions.
(I myself have no skin in the game either way)
Is Webpack beyond fixable? Tech has always been about reinventing the wheels, but the JS community seems to dial this up to a whole new level.
Isn't Webpack 4 heading towards Zero Configuration?
Isn't Webpack 4 making many performance improvements?
This isn't to say i dislike Parcel. I mean God I wish Rails could have picked up on it as default.
If anyone's looking for more info on this topic, my React/Redux links list has a large section of additional posts on improving Webpack build perf, code splitting, bundle size optimization, and other related techniques [3].
[0] https://github.com/webpack/webpack/issues/6244
[1] https://twitter.com/TheLarkInn/status/945486181575340032
[2] https://twitter.com/TheLarkInn/status/954053251854344192
[3] https://github.com/markerikson/react-redux-links/blob/master...
It looks like google uses bazel (a parallel dependency graph based build) internally and they have 1-2 second rebuild times on apps much larger then Slack [0].
0 - https://medium.com/@Jakeherringbone/what-angular-is-doing-wi...
I think it's a story of PostgreSQL vs Mongo - do you start out with conservative correctness and slowly expand your feature set, or do you advertise a lot of (poorly imolemented) features, and with the large userbase slowly increase your quality.
What a lot of devs may not be aware of, if their projects aren't of a certain scale & complexity (support for legacy code/library-choices/extreme-modularity/etc.) is that the magical nearly-instant hot-module reloading you experience with a clean, "normal" project should not be taken for granted because webpack builds/reloading can become a monster! Not to say you can't scale up good webpack performance (obviously slack has) just that it's not an automatic thing but something that requires some TLC.
Thanks for taking the time to share slack team!
We have multiple sites, each of which has it's own theme. Our various sass files check the theme variable passed into the sass loader, and decide on the correct values for particular styles. Our react components import the stylesheet and reference values accordingly. We also have a spattering of old backbone on some pages, so it's not just react involved.
Unfortunately, this means that we have to build our entire application for each theme. This takes an excruciating amount of time. Parallel Webpack makes it somewhat manageable, but I'd like to eliminate building for each theme altogether.
Any ideas on paths we can look into? If our application was all React, I'd consider styled components or a theme HOC. It's not though, so I've put those options on the back burner for the moment.
My latest projects use polymer and a custom built service (in go) to automatically parse entry points to my application and index the required files. When a HTTP2 connection is made -- and the browser supports push, I will automatically push all the required files. With browsers like chrome the results are near instant and I have full control over what gets pushed or not.
Personally I think we need to stop hacking the web together and properly solve these problems. I think HTTP2 with push is a good step in that direction.
I think webpack is a mess, but I think it really is just a reflection of the complexity of the web platform.
I don't see how you can work on a modern JS application, understand HTTP/2, and think HTTP/2 replaces Webpack. Pick two...
Webpack is used for a lot of things -- that it should not be used for. As I posted above many of the things it is used for should out of band of your blunder.
HTTP2 removes the need for bundling by allowing a smart web server either learn, or be told what files will be required for rendering to be pushed on the first request from the client. This eliminates the multiple request / and connections required in HTTP1 -- even with 4 pipelines that can be a lot of round trip request. If your application was not smart enough to know what to push to the client HTTP2 can allow multiple request over the same connection again negating the need for bundling.
> it is incorrect to say that HTTP/2 is a replacement for Webpack.
Take a look back over the thread. They didn't say that. They said it was a step in the right direction. Then somebody started putting words in their mouth.
We did a lot of study and testing on HTTP/2 and we found that your claims are entirely incorrect. But don't take my word for it, see the stats!
https://medium.com/webpack/webpack-http-2-7083ec3f3ce6
HOWEVER! HTTP/2 and webpack become even more powerful when used together! This is something we are really excited to share and build on!
Most of the things you described live outside of webpack, and webpack is NOT required to use them.
I think webpack is a mess, but will probably end up being the mess we're stuck with for sometime, because while it is complicated, it does solve a lot of problems. I see a lot of parallel with the GNU make and autotools setups used to build most C projects. The layered way that autoconf, configure, and make build configuration to compile and install programs is pretty complex (to my eye). Sure, it could probably be simplified a bit, but cross compiling code that dynamically links to libraries and installing it on different operating systems is just a complex problem.