Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Upgrade dev build tooling (Babel 6 -> 7, Webpack 1 -> 4) #1235

Merged
merged 4 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"presets": ["react", "es2015", "stage-0"],
"plugins": [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-class-properties", { "loose": false }]
],
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-flow"]
}
3 changes: 2 additions & 1 deletion backend/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"babelify": "^6.1.3",
"tap-browser-color": "^0.1.2",
"tape": "^4.0.1",
"tape-catch": "^1.0.4"
"tape-catch": "^1.0.4",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"es6-map": "^0.1.1",
Expand Down
30 changes: 12 additions & 18 deletions backend/integration/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
'use strict';

const {readFileSync} = require('fs');
const {resolve} = require('path');

module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
Expand All @@ -29,23 +32,14 @@ module.exports = {
},

module: {

// require
unknownContextRegExp: /$^/,
unknownContextCritical: false,

// require(expr)
exprContextRegExp: /$^/,
exprContextCritical: false,

// require("prefix" + expr + "surfix")
wrappedContextRegExp: /$^/,
wrappedContextCritical: false,

loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this spread operator really needed? You could remove the object braces and set options to the result of JSON.parse

Maybe I'm missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, I thought I might add some custom options to individual configs but that turned out not to be necessary.

},
},
],
},
};
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"dependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-transform-flow-strip-types": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"adm-zip": "^0.4.7",
"babel-core": "6.3.21",
"babel-eslint": "6.0.4",
"babel-jest": "22.1.0",
"babel-loader": "6.2.0",
"babel-preset-es2015": "6.3.13",
"babel-preset-react": "6.3.13",
"babel-preset-stage-0": "6.3.13",
"babel-eslint": "6",
"babel-loader": "^8.0.4",
"child-process-promise": "^2.2.1",
"classnames": "2.2.1",
"cli-spinners": "^1.0.0",
Expand All @@ -22,23 +23,22 @@
"gh-pages": "^1.0.0",
"immutable": "3.7.6",
"jest": "22.1.4",
"json-loader": "0.5.4",
"log-update": "^2.0.0",
"lru-cache": "^4.1.3",
"memoize-one": "^3.1.1",
"node-libs-browser": "0.5.3",
"nullthrows": "^1.0.0",
"object-assign": "4.0.1",
"prop-types": "^15.6.1",
"raw-loader": "^0.5.1",
"react": "^16.5.2",
"react-color": "^2.11.7",
"react-dom": "^16.5.2",
"react-portal": "^3.1.0",
"react-virtualized-auto-sizer": "^1.0.2",
"react-window": "^1.1.1",
"semver": "^5.5.1",
"webpack": "1.12.9"
"webpack": "^4.26.0",
"webpack-cli": "^3.1.2"
},
"license": "BSD-3-Clause",
"repository": "facebook/react-devtools",
Expand Down
35 changes: 17 additions & 18 deletions packages/react-devtools-core/webpack.backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,37 @@
*/
'use strict';

var webpack = require('webpack');
var __DEV__ = process.env.NODE_ENV !== 'production';
const {readFileSync} = require('fs');
const {resolve} = require('path');
const webpack = require('webpack');

const __DEV__ = process.env.NODE_ENV !== 'production';

module.exports = {
debug: true,
devtool: 'source-map',
mode: __DEV__ ? 'development' : 'production',
devtool: __DEV__ ? 'source-map' : false,
entry: {
backend: './src/backend.js',
},
output: {
path: __dirname + '/build', // eslint-disable-line no-path-concat
path: __dirname + '/build',
filename: '[name].js',
library: 'ReactDevToolsBackend',
libraryTarget: 'umd',
},
plugins: __DEV__ ? [] : [
// Ensure we get production React
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
// Remove dead code but keep it readable:
new webpack.optimize.UglifyJsPlugin({
mangle: false,
beautify: true,
}),
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
Copy link

@hugmanrique hugmanrique Nov 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as above (there are more occurences below, won't comment on those).

},
},
],
},
};

39 changes: 18 additions & 21 deletions packages/react-devtools-core/webpack.standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
*/
'use strict';

var webpack = require('webpack');
var __DEV__ = process.env.NODE_ENV !== 'production';
const {readFileSync} = require('fs');
const {resolve} = require('path');
const webpack = require('webpack');

const __DEV__ = process.env.NODE_ENV !== 'production';

module.exports = {
debug: true,
devtool: 'source-map',
mode: __DEV__ ? 'development' : 'production',
devtool: __DEV__ ? 'source-map' : false,
target: 'electron-main',
externals: ['ws'],
entry: {
standalone: './src/standalone.js',
},
// this lets us `require('fs')` etc
target: 'electron',
node: {
// don't replace __dirname, electron will handle it
__dirname: false,
},
output: {
path: __dirname + '/build', // eslint-disable-line no-path-concat
filename: '[name].js',
Expand All @@ -35,18 +34,16 @@ module.exports = {
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
// Remove dead code but keep it readable:
new webpack.optimize.UglifyJsPlugin({
mangle: false,
beautify: true,
}),
],
externals: ['ws'],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
},
},
],
},
};
21 changes: 14 additions & 7 deletions shells/plain/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
*/
'use strict';

const {readFileSync} = require('fs');
const {resolve} = require('path');

module.exports = {
devtool: false, //'cheap-module-eval-source-map',
mode: 'development',
devtool: false,
entry: {
backend: './backend.js',
container: './container.js',
Expand All @@ -19,12 +23,15 @@ module.exports = {
path: __dirname + '/build',
filename: '[name].js',
},

module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
},
},
],
},
};
21 changes: 14 additions & 7 deletions shells/theme-preview/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@
*/
'use strict';

const {readFileSync} = require('fs');
const {resolve} = require('path');

module.exports = {
devtool: false, //'cheap-module-eval-source-map',
mode: 'development',
devtool: 'cheap-module-eval-source-map',
entry: {
application: './application.js',
},
output: {
path: __dirname + '/build',
filename: '[name].js',
},

module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
},
},
],
},
};
30 changes: 14 additions & 16 deletions shells/webextension/webpack.backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@
*/
'use strict';

var webpack = require('webpack');
const {readFileSync} = require('fs');
const {resolve} = require('path');

var __DEV__ = process.env.NODE_ENV !== 'production';
const __DEV__ = process.env.NODE_ENV !== 'production';

module.exports = {
devtool: __DEV__ ? '#cheap-module-eval-source-map' : false,
mode: __DEV__ ? 'development' : 'production',
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
entry: {
backend: './src/backend.js',
},
output: {
path: __dirname + '/build',
filename: '[name].js',
},

module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
},
},
],
},

plugins: [new webpack.ProvidePlugin({
'Object.create': __dirname + '/helpers/object-create.js',
Map: __dirname + '/helpers/map.js',
WeakMap: __dirname + '/helpers/weak-map.js',
Set: __dirname + '/helpers/set.js',
})],
};
33 changes: 18 additions & 15 deletions shells/webextension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@
*/
'use strict';

var webpack = require('webpack');
var __DEV__ = process.env.NODE_ENV !== 'production';
const {readFileSync} = require('fs');
const {resolve} = require('path');
const webpack = require('webpack');

const __DEV__ = process.env.NODE_ENV !== 'production';

module.exports = {
devtool: __DEV__ ? '#cheap-module-eval-source-map' : false,
mode: __DEV__ ? 'development' : 'production',
devtool: __DEV__ ? 'cheap-module-eval-source-map' : false,
entry: {
main: './src/main.js',
background: './src/background.js',
inject: './src/GlobalHook.js',
contentScript: './src/contentScript.js',
inject: './src/GlobalHook.js',
main: './src/main.js',
panel: './src/panel.js',
},
output: {
Expand All @@ -30,17 +34,16 @@ module.exports = {
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
// Remove dead code but keep it readable:
new webpack.optimize.UglifyJsPlugin({
mangle: false,
beautify: true,
}),
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
}],
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
...JSON.parse(readFileSync(resolve(__dirname, '../../.babelrc'))),
},
},
],
},
};
Loading