@samitouri / QOS-React / commits / 9340083395

Scheduling Profiler: Add Fast Refresh (#19757)

E-Liang Tan committed Sep 3, 2020 at 21:17 UTC 93400833956d4aa5b3136fb5883142a70a4f54e6
4 files changed +33 -7
package.json
+1 -1
@@ -104,7 +104,7 @@
104 },
105 "scripts": {
106 "build": "node ./scripts/rollup/build.js",
107 - "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer --type=NODE",
107 + "build-for-devtools": "cross-env RELEASE_CHANNEL=experimental yarn build react/index,react-dom,react-is,react-debug-tools,scheduler,react-test-renderer,react-refresh --type=NODE",
108 "linc": "node ./scripts/tasks/linc.js",
109 "lint": "node ./scripts/tasks/eslint.js",
110 "lint-build": "node ./scripts/rollup/validate/index.js",
packages/react-devtools-scheduling-profiler/package.json
+1
@@ -17,6 +17,7 @@
17 "regenerator-runtime": "^0.13.7"
18 },
19 "devDependencies": {
20 + "@pmmmwh/react-refresh-webpack-plugin": "^0.4.1",
21 "babel-loader": "^8.1.0",
22 "css-loader": "^4.2.1",
23 "file-loader": "^6.0.0",
packages/react-devtools-scheduling-profiler/webpack.config.js
+10 -4
@@ -3,23 +3,24 @@
3 const {resolve} = require('path');
4 const {DefinePlugin} = require('webpack');
5 const HtmlWebpackPlugin = require('html-webpack-plugin');
6 +const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
7
8 const NODE_ENV = process.env.NODE_ENV;
9 if (!NODE_ENV) {
10 console.error('NODE_ENV not set');
11 process.exit(1);
12 }
13 +const __DEV__ = NODE_ENV === 'development';
14
15 const TARGET = process.env.TARGET;
16 if (!TARGET) {
17 console.error('TARGET not set');
18 process.exit(1);
19 }
20 +const shouldUseDevServer = TARGET === 'local';
21
22 const builtModulesDir = resolve(__dirname, '..', '..', 'build', 'node_modules');
23
21 -const __DEV__ = NODE_ENV === 'development';
22 -
24 const imageInlineSizeLimit = 10000;
25
26 const config = {
@@ -32,6 +33,7 @@ const config = {
33 alias: {
34 react: resolve(builtModulesDir, 'react'),
35 'react-dom': resolve(builtModulesDir, 'react-dom'),
36 + 'react-refresh': resolve(builtModulesDir, 'react-refresh'),
37 },
38 },
39 plugins: [
@@ -43,7 +45,8 @@ const config = {
45 new HtmlWebpackPlugin({
46 title: 'React Concurrent Mode Profiler',
47 }),
46 - ],
48 + shouldUseDevServer && new ReactRefreshWebpackPlugin(),
49 + ].filter(Boolean),
50 module: {
51 rules: [
52 {
@@ -56,6 +59,9 @@ const config = {
59 'react-devtools-shared',
60 'babel.config.js',
61 ),
62 + plugins: shouldUseDevServer
63 + ? [resolve(builtModulesDir, 'react-refresh/babel')]
64 + : [],
65 },
66 },
67 {
@@ -87,7 +93,7 @@ const config = {
93 },
94 };
95
90 -if (TARGET === 'local') {
96 +if (shouldUseDevServer) {
97 config.devServer = {
98 hot: true,
99 port: 8080,
yarn.lock
+21 -2
@@ -1821,6 +1821,18 @@
1821 universal-user-agent "^3.0.0"
1822 url-template "^2.0.8"
1823
1824 +"@pmmmwh/react-refresh-webpack-plugin@^0.4.1":
1825 + version "0.4.1"
1826 + resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.4.1.tgz#a4db0ed8e58c2f8566161c9a8cdf1d095c9a891b"
1827 + integrity sha512-MzM87WdX2r2KRFfhEho7oGyK1XRE/J9WwjB3v6oLQHN0dzBypBZxSWjnoYx+RWneRCsg8Sin1myf+EjX1fqIbQ==
1828 + dependencies:
1829 + ansi-html "^0.0.7"
1830 + error-stack-parser "^2.0.6"
1831 + html-entities "^1.2.1"
1832 + native-url "^0.2.6"
1833 + schema-utils "^2.6.5"
1834 + source-map "^0.7.3"
1835 +
1836 "@reach/auto-id@0.2.0":
1837 version "0.2.0"
1838 resolved "https://registry.yarnpkg.com/@reach/auto-id/-/auto-id-0.2.0.tgz#97f9e48fe736aa5c6f4f32cf73c1f19d005f8550"
@@ -2592,7 +2604,7 @@ ansi-gray@^0.1.1:
2604 dependencies:
2605 ansi-wrap "0.1.0"
2606
2595 -ansi-html@0.0.7:
2607 +ansi-html@0.0.7, ansi-html@^0.0.7:
2608 version "0.0.7"
2609 resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e"
2610 integrity sha1-gTWEAhliqenm/QOflA0S9WynhZ4=
@@ -9509,6 +9521,13 @@ nanomatch@^1.2.9:
9521 snapdragon "^0.8.1"
9522 to-regex "^3.0.1"
9523
9524 +native-url@^0.2.6:
9525 + version "0.2.6"
9526 + resolved "https://registry.yarnpkg.com/native-url/-/native-url-0.2.6.tgz#ca1258f5ace169c716ff44eccbddb674e10399ae"
9527 + integrity sha512-k4bDC87WtgrdD362gZz6zoiXQrl40kYlBmpfmSjwRO1VU0V5ccwJTlxuE72F6m3V0vc1xOf6n3UCP9QyerRqmA==
9528 + dependencies:
9529 + querystring "^0.2.0"
9530 +
9531 natural-compare-lite@~1.4.0:
9532 version "1.4.0"
9533 resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4"
@@ -10900,7 +10919,7 @@ querystring-es3@^0.2.0, querystring-es3@~0.2.0:
10919 resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
10920 integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=
10921
10903 -querystring@0.2.0:
10922 +querystring@0.2.0, querystring@^0.2.0:
10923 version "0.2.0"
10924 resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
10925 integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=