-
Notifications
You must be signed in to change notification settings - Fork 282
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 from 5.0.0-alpha.17 to 5.0.0-beta.28 #579
Conversation
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.
l converted this PR to a draft so we don't accidentally merge
Ok it looks like 5.0.0-beta.8 is about as far as we can go for now, since beta.9 enables tree shaking which seems to break some relocation stuff and I'm not sure how to turn it off. |
I believe the tests should be passing now, ready for review. |
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.
I got a few warnings when compiling Vercel CLI using ncc from this branch. Is this expected?
ncc: Version 0.23.0
ncc: Compiling file index.js
<w> [webpack.cache.PackFileCacheStrategy] Restoring pack failed from /var/folders/v7/6kzxdgb93x328tk9pg633s200000gn/T/ncc-cache/ncc_6c640045e9.pack: TypeError: this.unserializable.add is not a function
<w> (during deserialization of webpack/lib/cache/PackFileCacheStrategy Pack)
ncc: Using typescript@3.9.3 (local user-provided)
(node:81518) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
@guybedford I also noticed that Likely because this message is no longer printed:
UpdateI made sure to run both before/after with the minify option and both excluded But I did notice that the source maps became 2x larger 🤔 |
@styfle thanks for looking into the details here:
|
Finally managed to get it all the way to the latest beta.28 depending on the PR at vercel/webpack-asset-relocator-loader#96 as well here. |
I've published and updated to webpack-asset-relocator-loader@0.8.0 here now. This should then be good to release as a new major. @styfle I will leave the rest to you here now, and just let me know if you spot any issues further. |
@guybedford I tried this PR on Vercel CLI and compared the time it takes too bootup and print the version. It is 2x slower than the bundle using ncc 0.18.5, even after several runs. Version 0.18.5
This PR
|
@sokra it seems like we have quite a significant performance drop here on the Webpack 5 upgrade path, despite disabling a lot of the tree-shaking functionality as discussed. Are there any other options that might help here? |
@styfle could you clarify if these numbers are before or after running |
@guybedford Those are three consecutive runs. I actually did many more but three got the point across that it was slower. I didn't do |
@styfle a version of these benchmarks with a |
@styfle there are a few things that are very important to ensure the correct function here, which you may not have done:
With the above, I tried four different runs here:
The above does show a slight slowdown with the latest Webpack 5 upgrade here, but not one that seems too significant to me. I would assume this difference comes down to subtle interop / wrapper function changes in Webpack, but perhaps Tobias can share more here. I've gone ahead and reenabled the treeshaking options. The remaining practical question, unless Tobias has further insights, is just whether a 3% increase in startup time is a genuine concern and if we want to not upgrade either project based on that. Personally I don't see it as significant, but it's certainly not my decision. |
@guybedford The startup time I mentioned earlier is not about
To reproduce the slowdown, please try the following: ## Build NCC
cd /tmp
git clone https://github.com/vercel/ncc
cd ncc
git checkout webpack-upgrade
yarn
yarn build
/tmp/ncc/dist/ncc/cli.js cache clean
## Build Vercel CLI with the local NCC
cd /tmp
git clone https://github.com/vercel/vercel
cd vercel
sed -i "" "s|@zeit/ncc|/tmp/ncc/dist/ncc/cli.js|g" ./packages/now-cli/scripts/build.ts
yarn
yarn build
## Run Vercel CLI and time it
time ./packages/now-cli/dist/index.js --version |
@styfle the numbers are above are exactly for the Vercel CLI build. |
(that is those sizes and ms counts are for |
Which version of Node.js are you running? |
I'm using Node 12.18.3 |
@styfle I dug into this and it looks like the source map is significantly reducing the execution time in Node.js - if you build without the sourcemap, the execution time reduces to 500ms. I would advise turning off the sourcemap entirely for this reason, possibly turning off minification as the bandwidth saving isn't really worth it there either. |
(that is - because the source map size increased, the execution time increased!) |
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.
Amazing work, thanks! 🤩
I got an error in compiled result with v0.24.0, but v0.23.0 works fine. I have not found any related issue in vercel/ncc, so I am not sure why it failed. But clearly v0.23.0 works. |
@3cp if you can share the exact replication steps as a new issue that would help. |
@guybedford here is a demo for the bug. https://github.com/3cp/ncc-bug
|
New issue created. |
This upgrades Webpack 5 from 5.0.0-alpha.17 to 5.0.0-alpha.23 which is enough to get the now-cli to build with ncc.
The upgrade path is quite difficult due to the use of experimental and internal APIs as well as the fact that there is a lot of movement on these alpha releases.
If CI passes here I'm going to attempt to progressively upgrade as far as I can as that would obviously be preferable.
//cc @styfle