-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Parcel2 v. Webpack - Build times are significantly slower #4566
Comments
If you mean that you see "optimizing foo...." for a while, that could also mean (because optimizing and packaging happens in parallel): |
Thanks for the tip! In case it's helpful, I ran parcel with the |
Does "webpack build - with Terser cache" correspond to "no changes" or "one string change"? BTW, it doesn't matter what you change (a string or something else), the JS AST handling is by far not intelligent enough to cache anything in that case, the packager has to run again. Is it possible that the two trace files are swapped? The cold cache one should be larger than the warm cache run. |
"no changes" I clarified the table above and also tested the other scenario - "webpack build - with Terser cahce, one string change", and I got results similar to the "no terser cache" case (~13s on my machine).
I'm pretty sure I didn't accidentally swap them, although I agree it is weird that something that should take more work would be smaller. Maybe something went wrong writing the profile to disk? (In an earlier attempt, I ran out of heap memory, and I noticed that it would still write something to disk, but it would be incomplete - maybe that happened, and I didn't notice?). To be extra sure, I ran it again, and here are links to the full set.
Per @wbinnssmith's suggestion, I gziped all four traces for faster downloading. It's only 69MB combined (!). |
Based on what I learned investigating #4565 about how to bypass the tree-shaking issue, I re-ran the perf benchmarks on an app that uses the more-granular import style. In these tests, I'm importing import Box from "@fluentui/react-northstar/dist/es/components/Box/Box";
import Provider from "@fluentui/react-northstar/dist/es/components/Provider/Provider";
import teamsTheme from "@fluentui/react-northstar/dist/es/themes/teams"; Parcel's bundle size is significantly smaller (631KiB) than in the original tests, and more comparable to webpack's (622Kib).
So that sped things up significantly, but it's still about 50% slower than webpack in the "one-string change" case and 3x slower in the "no cache" case. |
I think this should be mainly solved now after the latest rewrite |
🐛 bug report
I've started trying to use Parcel2 in a real-life situation, and I'm noticed that the parcel build times are significantly slower than webpack's, even with a warm cache, as long as there is at least one change since the last build. (It also makes significantly larger bundles - see #4565).
Like all real-life situations, it's complicated, so I tried to create a simplified repro environment in the
fluentui-button-babel
branch of this repo. It's a simple react app with a singleButton
component from the@fluentui/react-northstar
library.🎛 Configuration (.babelrc, package.json, cli command)
Webpack (full config here):
babel-loader
with this config:production
flag set totrue
, which enables minification throughTerserWebpackPlugin
and scope-hoisting/tree-shaking throughModuleConcatinationPlugin
, among other optimizations.Parcel configuration:
.parcelrc
file, which means that the default babel transformer is being used.parcel build src/index.html
src/index.html:
src/index.tsx:
src/components/App.ts:
🤔 Expected Behavior
Parcel should be at least as fast as webpack, hopefully significantly faster if there is a warm cache.
😯 Current Behavior
Here's a comparison of Parcel v. Webpack build times in various scenarios.
All scenarios (both parcel and webpack) are:
parcel
andbabel-loader
for webpack).💁 Possible Solution
There are probably multiple ways to make things faster. One thing I noticed is that a lot of the time each build (even with a warm parcel cache) is spent during the "optimization" phase. It looks like
TerserWebpackPlugin
might be leveraging some caching that we are not. It might also be related to #4565 - if we could successfully tree-shake the stuff that webpack can, all the later steps would be faster.🔦 Context
Trying to build a real-world app that uses
@fluentui/react-northstar
and parcel2.💻 Code Sample
See the
fluentui-button-babel
branch of this repo.🌍 Your Environment
The text was updated successfully, but these errors were encountered: