-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
chore: upgrade webpack@5 to fix CI builds #6509
Conversation
@@ -1,7 +1,7 @@ | |||
const path = require('path'); | |||
require('dotenv').config({ path: path.join(__dirname, '..', '..', '.env') }); | |||
const webpack = require('webpack'); | |||
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); | |||
const FriendlyErrorsWebpackPlugin = require('@soda/friendly-errors-webpack-plugin'); |
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.
friendly-errors-webpack-plugin
does not supportwebpack@5
and is archived on GitHub.@soda/friendly-errors-webpack-plugin
is a fork which supportswebpack@5
.
new webpack.IgnorePlugin({ | ||
resourceRegExp: /^\.\/locale$/, | ||
contextRegExp: /moment$/, | ||
}), |
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.
The syntax for IgnorePlugin changed (new documentation):
If you are using
IgnorePlugin
with a regular expression as argument, it takes anoptions
object now:new IgnorePlugin({ resourceRegExp: /regExp/ })
.
new webpack.ProvidePlugin({ | ||
Buffer: ['buffer', 'Buffer'], | ||
process: 'process', | ||
}), |
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.
Webpack 5 no longer includes automatic polyfills for Node.js:
In the early days, webpack's aim was to allow running most Node.js modules in the browser, but the module landscape changed and many module uses are now written mainly for frontend purposes. Webpack <= 4 ships with polyfills for many of the Node.js core modules, which are automatically applied once a module uses any of the core modules (i.e. the
crypto
module).While this makes using modules written for Node.js easier, it adds these huge polyfills to the bundle. In many cases these polyfills are unnecessary.
Webpack 5 stops automatically polyfilling these core modules and focus on frontend-compatible modules. Our goal is to improve compatibility with the web platform, where Node.js core modules are not available.
…
It's possible to manually add a polyfill for a Node.js core module. An error message will give a hint on how to achieve that.
This (and the below fallback
configuration lines) follow those hints.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Dependencies are a mess right now, so they will be updated as part of a PR by maintainers. |
Summary
Upgrades Webpack to version 5 to fix #6502, which is preventing successful builds due to an interaction between Webpack 4 and Node versions 17 and above.
Test plan
Tests ran locally and had one failure with
yarn test:all
. Unfortunately, it appears tests are also not functioning in CI, as Cypress is timing out waiting for the test server to boot on 18F’s fork.1 test failure in
editorial_workflow_migration_spec_github_backend_rest.js
editorial_workflow_migration_spec_github_backend_rest.js.mp4
What I’ve been able to gather:
I’d appreciate assistance if a contributor understands why this test may be failing. ❤️
Checklist
Please add a
x
inside each checkbox:yarn format
.yarn test
.Fresh photo of Toulouse, for y’all! 🙂 More on #6498.