Skip to content

Commit 4ae372f

Browse files
Update from webpack4 to webpack5 (#7507)
1 parent 0b5907f commit 4ae372f

File tree

3 files changed

+702
-1010
lines changed

3 files changed

+702
-1010
lines changed

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@ant-design/icons": "^4.2.1",
4848
"@redash/viz": "file:viz-lib",
4949
"ace-builds": "^1.4.12",
50-
"antd": "^4.4.3",
50+
"antd": "4.4.3",
5151
"axios": "0.27.2",
5252
"axios-auth-refresh": "3.3.6",
5353
"bootstrap": "^3.4.1",
@@ -100,6 +100,7 @@
100100
"@types/sql-formatter": "^2.3.0",
101101
"@typescript-eslint/eslint-plugin": "^2.10.0",
102102
"@typescript-eslint/parser": "^2.10.0",
103+
"assert": "^2.1.0",
103104
"atob": "^2.1.2",
104105
"babel-eslint": "^10.0.3",
105106
"babel-jest": "^24.1.0",
@@ -139,20 +140,23 @@
139140
"mockdate": "^2.0.2",
140141
"npm-run-all": "^4.1.5",
141142
"prettier": "3.3.2",
143+
"process": "^0.11.10",
142144
"raw-loader": "^0.5.1",
143145
"react-refresh": "^0.14.0",
144146
"react-test-renderer": "^16.14.0",
145147
"request-cookies": "^1.1.0",
146148
"source-map-loader": "^1.1.3",
149+
"stream-browserify": "^3.0.0",
147150
"style-loader": "^2.0.0",
148-
"typescript": "^4.1.2",
151+
"typescript": "4.1.2",
152+
"url": "^0.11.4",
149153
"url-loader": "^4.1.1",
150-
"webpack": "^4.46.0",
151-
"webpack-build-notifier": "^2.3.0",
154+
"webpack": "^5.101.3",
155+
"webpack-build-notifier": "^3.0.1",
152156
"webpack-bundle-analyzer": "^4.9.0",
153157
"webpack-cli": "^4.10.0",
154158
"webpack-dev-server": "^4.15.1",
155-
"webpack-manifest-plugin": "^2.0.4"
159+
"webpack-manifest-plugin": "^5.0.1"
156160
},
157161
"optionalDependencies": {
158162
"fsevents": "^2.3.2"

webpack.config.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const webpack = require("webpack");
44
const HtmlWebpackPlugin = require("html-webpack-plugin");
55
const WebpackBuildNotifierPlugin = require("webpack-build-notifier");
6-
const ManifestPlugin = require("webpack-manifest-plugin");
6+
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
77
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
88
const CopyWebpackPlugin = require("copy-webpack-plugin");
99
const LessPluginAutoPrefix = require("less-plugin-autoprefix");
@@ -76,15 +76,21 @@ const config = {
7676
publicPath: staticPath
7777
},
7878
node: {
79-
fs: "empty",
80-
path: "empty"
8179
},
8280
resolve: {
8381
symlinks: false,
8482
extensions: [".js", ".jsx", ".ts", ".tsx"],
8583
alias: {
8684
"@": appPath,
8785
extensions: extensionPath
86+
},
87+
fallback: {
88+
fs: false,
89+
url: require.resolve("url/"),
90+
stream: require.resolve("stream-browserify"),
91+
assert: require.resolve("assert/"),
92+
util: require.resolve("util/"),
93+
process: require.resolve("process/browser"),
8894
}
8995
},
9096
plugins: [
@@ -109,7 +115,7 @@ const config = {
109115
new MiniCssExtractPlugin({
110116
filename: "[name].[chunkhash].css"
111117
}),
112-
new ManifestPlugin({
118+
new WebpackManifestPlugin({
113119
fileName: "asset-manifest.json",
114120
publicPath: ""
115121
}),
@@ -122,7 +128,13 @@ const config = {
122128
{ from: "client/app/assets/fonts", to: "fonts/" }
123129
],
124130
}),
125-
isHotReloadingEnabled && new ReactRefreshWebpackPlugin({ overlay: false })
131+
isHotReloadingEnabled && new ReactRefreshWebpackPlugin({ overlay: false }),
132+
new webpack.ProvidePlugin({
133+
// Make a global `process` variable that points to the `process` package,
134+
// because the `util` package expects there to be a global variable named `process`.
135+
// Thanks to https://stackoverflow.com/a/65018686/14239942
136+
process: 'process/browser'
137+
})
126138
].filter(Boolean),
127139
optimization: {
128140
splitChunks: {
@@ -137,6 +149,9 @@ const config = {
137149
test: /\.js$/,
138150
enforce: "pre",
139151
use: ["source-map-loader"],
152+
resolve: {
153+
fullySpecified: false
154+
}
140155
},
141156
{
142157
test: /\.(t|j)sx?$/,
@@ -233,7 +248,7 @@ const config = {
233248
}
234249
]
235250
},
236-
devtool: isProduction ? "source-map" : "cheap-eval-module-source-map",
251+
devtool: isProduction ? "source-map" : "eval-cheap-module-source-map",
237252
stats: {
238253
children: false,
239254
modules: false,

0 commit comments

Comments
 (0)