added react native feature flags (#22199)
lunaruan commented 3 days ago • This PR adds separate DevTools feature flag configurations for react-devtools-core. It also breaks the builds down into facebook specific and open source flags so we can experiment in React Native. Tested yarn build:standalone, yarn build:backend, yarn build:standalone:fb, and yarn build:backend:fb and inspected the output to make sure each package used the correct feature flags (the first two use core-oss and the latter two use fb-oss.
Luna Ruan committed
Aug 30, 2021 at 14:12 UTC
36f0005b994aa429d4d8f7ac6c1cab3cacf76385
6 files changed
+77
-4
packages/react-devtools-core/package.json
+2
@@ -18,7 +18,9 @@
18
"scripts": {
19
"build": "yarn build:backend && yarn build:standalone",
20
"build:backend": "cross-env NODE_ENV=production webpack --config webpack.backend.js",
21
+ "build:backend:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=core/backend-fb webpack --config webpack.backend.js",
22
"build:standalone": "cross-env NODE_ENV=production webpack --config webpack.standalone.js",
23
+ "build:standalone:fb": "cross-env NODE_ENV=production FEATURE_FLAG_TARGET=core/standalone-fb webpack --config webpack.standalone.js",
24
"prepublish": "yarn run build",
25
"start:backend": "cross-env NODE_ENV=development webpack --config webpack.backend.js --watch",
26
"start:standalone": "cross-env NODE_ENV=development webpack --config webpack.standalone.js --watch"
packages/react-devtools-core/webpack.backend.js
+3
-1
@@ -24,6 +24,8 @@ const __DEV__ = NODE_ENV === 'development';
24
25
const DEVTOOLS_VERSION = getVersionString();
26
27
+const featureFlagTarget = process.env.FEATURE_FLAG_TARGET || 'core/backend-oss';
28
+
29
// This targets RN/Hermes.
30
process.env.BABEL_CONFIG_ADDITIONAL_TARGETS = JSON.stringify({
31
ie: '11',
@@ -47,7 +49,7 @@ module.exports = {
49
alias: {
50
react: resolve(builtModulesDir, 'react'),
51
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
50
- 'react-devtools-feature-flags': resolveFeatureFlags('core/backend'),
52
+ 'react-devtools-feature-flags': resolveFeatureFlags(featureFlagTarget),
53
'react-dom': resolve(builtModulesDir, 'react-dom'),
54
'react-is': resolve(builtModulesDir, 'react-is'),
55
scheduler: resolve(builtModulesDir, 'scheduler'),
packages/react-devtools-core/webpack.standalone.js
+4
-1
@@ -24,6 +24,9 @@ const __DEV__ = NODE_ENV === 'development';
24
25
const DEVTOOLS_VERSION = getVersionString();
26
27
+const featureFlagTarget =
28
+ process.env.FEATURE_FLAG_TARGET || 'core/standalone-oss';
29
+
30
const babelOptions = {
31
configFile: resolve(
32
__dirname,
@@ -50,7 +53,7 @@ module.exports = {
53
alias: {
54
react: resolve(builtModulesDir, 'react'),
55
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
53
- 'react-devtools-feature-flags': resolveFeatureFlags('core/standalone'),
56
+ 'react-devtools-feature-flags': resolveFeatureFlags(featureFlagTarget),
57
'react-dom': resolve(builtModulesDir, 'react-dom'),
58
'react-is': resolve(builtModulesDir, 'react-is'),
59
scheduler: resolve(builtModulesDir, 'scheduler'),
packages/react-devtools-shared/buildUtils.js
+8
-2
@@ -11,12 +11,18 @@ const {resolve} = require('path');
11
function resolveFeatureFlags(target) {
12
let flagsPath;
13
switch (target) {
14
- case 'core/backend':
15
- case 'core/standalone':
14
case 'inline':
15
case 'shell':
16
flagsPath = 'DevToolsFeatureFlags.default';
17
break;
18
+ case 'core/backend-oss':
19
+ case 'core/standalone-oss':
20
+ flagsPath = 'DevToolsFeatureFlags.core-oss';
21
+ break;
22
+ case 'core/backend-fb':
23
+ case 'core/standalone-fb':
24
+ flagsPath = 'DevToolsFeatureFlags.core-fb';
25
+ break;
26
case 'extension-oss':
27
flagsPath = 'DevToolsFeatureFlags.extension-oss';
28
break;
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-fb.js
new
+30
@@ -0,0 +1,30 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+/************************************************************************
11
+ * This file is forked between different DevTools implementations.
12
+ * It should never be imported directly!
13
+ * It should always be imported from "react-devtools-feature-flags".
14
+ ************************************************************************/
15
+
16
+export const enableProfilerChangedHookIndices = true;
17
+export const isInternalFacebookBuild = true;
18
+
19
+/************************************************************************
20
+ * Do not edit the code below.
21
+ * It ensures this fork exports the same types as the default flags file.
22
+ ************************************************************************/
23
+
24
+import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
25
+import typeof * as ExportsType from './DevToolsFeatureFlags.core-fb';
26
+
27
+// eslint-disable-next-line no-unused-vars
28
+type Check<_X, Y: _X, X: Y = _X> = null;
29
+// eslint-disable-next-line no-unused-expressions
30
+(null: Check<ExportsType, FeatureFlagsType>);
packages/react-devtools-shared/src/config/DevToolsFeatureFlags.core-oss.js
new
+30
@@ -0,0 +1,30 @@
1
+/**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow
8
+ */
9
+
10
+/************************************************************************
11
+ * This file is forked between different DevTools implementations.
12
+ * It should never be imported directly!
13
+ * It should always be imported from "react-devtools-feature-flags".
14
+ ************************************************************************/
15
+
16
+export const enableProfilerChangedHookIndices = false;
17
+export const isInternalFacebookBuild = false;
18
+
19
+/************************************************************************
20
+ * Do not edit the code below.
21
+ * It ensures this fork exports the same types as the default flags file.
22
+ ************************************************************************/
23
+
24
+import typeof * as FeatureFlagsType from './DevToolsFeatureFlags.default';
25
+import typeof * as ExportsType from './DevToolsFeatureFlags.core-oss';
26
+
27
+// eslint-disable-next-line no-unused-vars
28
+type Check<_X, Y: _X, X: Y = _X> = null;
29
+// eslint-disable-next-line no-unused-expressions
30
+(null: Check<ExportsType, FeatureFlagsType>);