Skip to content

Commit 7edce8e

Browse files
tyao1facebook-github-bot
authored andcommitted
Upgrade webpack from 4 to 5
Summary: Upgrade to webpack5 so that we don't have to pass `NODE_OPTIONS=--openssl-legacy-provider` for all the commands. Reviewed By: andreqi Differential Revision: D60187892 fbshipit-source-id: 8792275247a786c0624cbde9e276199e2036dcae
1 parent 00c8e08 commit 7edce8e

File tree

8 files changed

+1901
-1821
lines changed

8 files changed

+1901
-1821
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"firefox-profile": "^1.0.2",
118118
"flow-bin": "^0.113.0",
119119
"fs-extra": "^3.0.1",
120-
"graphql": "^14.4.2",
120+
"graphql": "^16.9.0",
121121
"jest": "^24.9.0",
122122
"lint-staged": "^7.0.5",
123123
"local-storage-fallback": "^4.1.1",
@@ -140,9 +140,9 @@
140140
"scheduler": "^0.0.0-50b50c26f",
141141
"style-loader": "^0.23.1",
142142
"web-ext": "^3.0.0",
143-
"webpack": "^4.41.3",
144-
"webpack-cli": "^3.1.2",
145-
"webpack-dev-server": "^3.10.0",
143+
"webpack": "^5.93.0",
144+
"webpack-cli": "^5.1.4",
145+
"webpack-dev-server": "^5.0.4",
146146
"yargs": "^14.2.0"
147147
}
148148
}

packages/relay-devtools-core/webpack.backend.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
const { resolve } = require('path');
9-
const { DefinePlugin } = require('webpack');
9+
const Webpack = require('webpack');
1010
const {
1111
getGitHubIssuesURL,
1212
getGitHubURL,
@@ -29,7 +29,7 @@ const DEVTOOLS_FEEDBACK_GROUP = getInternalDevToolsFeedbackGroup();
2929

3030
module.exports = {
3131
mode: 'development', // TODO TESTING __DEV__ ? 'development' : 'production',
32-
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
32+
devtool: __DEV__ ? 'eval-cheap-module-source-map' : false,
3333
entry: {
3434
backend: './src/backend.js',
3535
},
@@ -38,16 +38,18 @@ module.exports = {
3838
filename: '[name].js',
3939

4040
// This name is important; standalone references it in order to connect.
41-
library: 'RelayDevToolsBackend',
42-
libraryTarget: 'umd',
41+
library: {
42+
name:'RelayDevToolsBackend',
43+
type: 'umd',
44+
}
4345
},
4446
resolve: {
4547
alias: {
4648
src: resolve(__dirname, '../../src'),
4749
},
4850
},
4951
plugins: [
50-
new DefinePlugin({
52+
new Webpack.DefinePlugin({
5153
__DEV__: true,
5254
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
5355
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,

packages/relay-devtools-core/webpack.standalone.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
const { resolve } = require('path');
9-
const { DefinePlugin } = require('webpack');
9+
const Webpack = require('webpack');
1010
const {
1111
getGitHubIssuesURL,
1212
getGitHubURL,
@@ -29,24 +29,26 @@ const DEVTOOLS_FEEDBACK_GROUP = getInternalDevToolsFeedbackGroup();
2929

3030
module.exports = {
3131
mode: __DEV__ ? 'development' : 'production',
32-
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
32+
devtool: __DEV__ ? 'eval-cheap-module-source-map' : false,
3333
target: 'electron-main',
3434
entry: {
3535
standalone: './src/standalone.js',
3636
},
3737
output: {
3838
path: __dirname + '/dist',
3939
filename: '[name].js',
40-
library: '[name]',
41-
libraryTarget: 'commonjs2',
40+
library: {
41+
name: '[name]',
42+
type: 'commonjs2',
43+
},
4244
},
4345
resolve: {
4446
alias: {
4547
src: resolve(__dirname, '../../src'),
4648
},
4749
},
4850
plugins: [
49-
new DefinePlugin({
51+
new Webpack.DefinePlugin({
5052
__DEV__: false,
5153
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
5254
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,

shells/browser/shared/webpack.backend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DEVTOOLS_FEEDBACK_GROUP = getInternalDevToolsFeedbackGroup();
3131

3232
module.exports = {
3333
mode: __DEV__ ? 'development' : 'production',
34-
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
34+
devtool: __DEV__ ? 'eval-cheap-module-source-map' : false,
3535
entry: {
3636
backend: './src/backend.js',
3737
},

shells/browser/shared/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DEVTOOLS_FEEDBACK_GROUP = getInternalDevToolsFeedbackGroup();
3131

3232
module.exports = {
3333
mode: __DEV__ ? 'development' : 'production',
34-
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
34+
devtool: __DEV__ ? 'eval-cheap-module-source-map' : false,
3535
entry: {
3636
background: './src/background.js',
3737
contentScript: './src/contentScript.js',

shells/dev/relay-app/FriendsList/createInBrowserNetwork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function createInBrowserNetwork() {
152152
function fetchQuery(request, variables) {
153153
return new Promise(resolve => {
154154
setTimeout(() => {
155-
resolve(graphql(schema, request.text, root, null, variables));
155+
resolve(graphql({schema, source: request.text, rootValue:root, variableValues: variables}));
156156
}, 1000 + Math.round(Math.random() * 1000));
157157
});
158158
}

shells/dev/webpack.config.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
const { resolve } = require('path');
9-
const { DefinePlugin } = require('webpack');
8+
const Webpack = require('webpack');
109
const {
1110
getGitHubIssuesURL,
1211
getGitHubURL,
1312
getInternalDevToolsFeedbackGroup,
1413
getVersionString,
1514
} = require('../utils');
15+
const path = require('path');
1616

1717
const NODE_ENV = process.env.NODE_ENV;
1818
if (!NODE_ENV) {
@@ -43,11 +43,11 @@ const config = {
4343
},
4444
resolve: {
4545
alias: {
46-
src: resolve(__dirname, '../../src'),
46+
src: path.resolve(__dirname, '../../src'),
4747
},
4848
},
4949
plugins: [
50-
new DefinePlugin({
50+
new Webpack.DefinePlugin({
5151
__DEV__: __DEV__,
5252
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
5353
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
@@ -84,18 +84,18 @@ const config = {
8484
},
8585
};
8686

87+
config.output = {
88+
path: path.resolve(__dirname, 'dist'),
89+
filename: '[name].js',
90+
publicPath: '/dist/',
91+
};
8792
if (TARGET === 'local') {
8893
config.devServer = {
94+
static: {
95+
directory:path.join(__dirname, '/'),
96+
},
8997
hot: true,
9098
port: 8080,
91-
clientLogLevel: 'warning',
92-
publicPath: '/dist/',
93-
stats: 'errors-only',
94-
};
95-
} else {
96-
config.output = {
97-
path: resolve(__dirname, 'dist'),
98-
filename: '[name].js',
9999
};
100100
}
101101

0 commit comments

Comments
 (0)