-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Upgrade webpack to 2.x #14786
Upgrade webpack to 2.x #14786
Conversation
It looks like there is now a webpack-provided way of creating the kind of long-term caching we were striving for with |
cc @jsnmoon for codemod goodness. Also, we should just get rid of react-hot for the moment. |
server/bundler/loader.js
Outdated
@@ -163,7 +163,7 @@ function singleEnsure( chunkName ) { | |||
module.exports = function( content ) { | |||
var sections; | |||
|
|||
this.cacheable && this.cacheable(); | |||
// this.cacheable && this.cacheable(); // TODO @ehg why did you comment this out? |
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.
No longer needed in webpack2. On by default.
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.
awesomesauce
client/reader/stream/index.jsx
Outdated
@@ -48,6 +48,7 @@ const HEADER_OFFSET_TOP = 46; | |||
const MIN_DISTANCE_BETWEEN_RECS = 4; // page size is 7, so one in the middle of every page and one on page boundries, sometimes | |||
const MAX_DISTANCE_BETWEEN_RECS = 30; | |||
|
|||
|
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.
:)
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.
oops!
@ehg why do we want codemods in this pr? Ideally we can keep this to just upgrading to webpack2 and trying to maintain the same feature set |
We don't. I'm just looping Jason in :) |
Also, I should explain myself a bit better here:
I've noticed quite a few problems involving tree-shaking and react-hot, so we might as well just remove it all together, then come back to it when/if we want it. It's pretty useless considering out iterative build times atm IMHO :) |
8801509
to
e1ace8f
Compare
HMR is now working in this branch! 🎉 What problems were you seeing @ehg |
Build Perf analysis: webpack 1.3.x build times:
webpack 2.6.1 build times:
webpack 2.3.2 build times: Airbnb employee says that 2.3.2 is faster.
All tests conducted on a 2015 Macbook Pro Conclusions: |
I've created a stats.json file with webpack 2.6.1 for use with the webpack build analysis tool located at: http://webpack.github.io/analyse/ . TODO: drop link to file I'm currently having some trouble figuring out what it all means, but there are some suggestions re. module name resolution etc that seem like they could speed up the builds. In particular this affects |
It wasn't so much that HMR/react-hot weren't working on my initial branch. Once I enabled tree-shaking, I got into some trouble. This was because of import hoisting with react-hot v1, but I've seen problems mentioned with v3 too. |
I'm not too happy about the DevEx performance hit that a straight migration to the latest webpack causes. I'm spinning a PR off of this one to try to speed things upcreating a dev-only DLL chunk. We used to do this but stopped because we ran into issues re. caching: #11867 By only doing this in dev, it shouldn't affect caching in prod |
For now i'll keep it in. If we need to strip it out in a future pr then so be it :( |
What about we migrate to |
Is there any reason to think 3.X will solve the perf issue? 2.3.2 is missing the two plugins essential for caching |
webpack/webpack#4863 is marked as
Oh, damn. I guess you could try forking |
We could also bundle calypso with the source for the two plugins in question and then delete the files when we upgrade: |
By using the |
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 works fine now on Windows. If that was the only blocker, you can 🚢 it :)
@samouri This PR needs a rebase |
Up until now I had only been testing local build times. I'm going to merge this in the next few hours so I just tested the docker build times as well. when running the command:
Thats a reduction from 6:41 --> 5:00 🎉 |
* Perf improvements: disable code-splitting, and use happypack * use happypack also on the server * re-enable code-splitting
5ab3170
to
0af5962
Compare
I wonder if we want to tweak https://github.com/amireh/happypack#threads-number at all. How many cores do our docker build instances get...? |
@blowery: definitely something we can and should tweak! We'll want to do some testing directly on the machines doing our docker builds. |
* Revert "Revert "Upgrade webpack to 2.x (#14786)" (#15617)" This reverts commit f1cffef. * Add in NameAllModulePlugins + update shrinkwrap * upgrade to 3.0 and name all modules/chunks * vendor chunks minChunks infinity so it only includes what we specify * Update shrinwrap + add peer dependency * cross-env for webpack-dashboard * remove copied NamedModulesPlugin * remove ChunkFileNamePlugin * fix error handling + modify readme.md * remove ajv, bump webpack3, update shrinkwrap * add ajv back in * delete cruft empty concat
Heavily building off of the work done by @ehg in #10799, I'm attempting to upgrade our build system to Webpack 2.x. One of the largest draws is the promise of tree shaking which can reduce the size of our bundles.
Problems to fix: