Minor code structure adjustments to the bundles.js file (#15079)
* simplify * fix error * use deepFreeze * move comments
Kunuk Nykjær committed
Apr 25, 2019 at 17:24 UTC
c530639dd21543ab8d7d9e83d53197cda234b26b
1 file changed
+35
-36
scripts/rollup/bundles.js
+35
-36
@@ -18,40 +18,44 @@ const bundleTypes = {
18
RN_FB_PROFILING: 'RN_FB_PROFILING',
19
};
20
21
-const UMD_DEV = bundleTypes.UMD_DEV;
22
-const UMD_PROD = bundleTypes.UMD_PROD;
23
-const UMD_PROFILING = bundleTypes.UMD_PROFILING;
24
-const NODE_DEV = bundleTypes.NODE_DEV;
25
-const NODE_PROD = bundleTypes.NODE_PROD;
26
-const NODE_PROFILING = bundleTypes.NODE_PROFILING;
27
-const FB_WWW_DEV = bundleTypes.FB_WWW_DEV;
28
-const FB_WWW_PROD = bundleTypes.FB_WWW_PROD;
29
-const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING;
30
-const RN_OSS_DEV = bundleTypes.RN_OSS_DEV;
31
-const RN_OSS_PROD = bundleTypes.RN_OSS_PROD;
32
-const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING;
33
-const RN_FB_DEV = bundleTypes.RN_FB_DEV;
34
-const RN_FB_PROD = bundleTypes.RN_FB_PROD;
35
-const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING;
21
+const {
22
+ UMD_DEV,
23
+ UMD_PROD,
24
+ UMD_PROFILING,
25
+ NODE_DEV,
26
+ NODE_PROD,
27
+ NODE_PROFILING,
28
+ FB_WWW_DEV,
29
+ FB_WWW_PROD,
30
+ FB_WWW_PROFILING,
31
+ RN_OSS_DEV,
32
+ RN_OSS_PROD,
33
+ RN_OSS_PROFILING,
34
+ RN_FB_DEV,
35
+ RN_FB_PROD,
36
+ RN_FB_PROFILING,
37
+} = bundleTypes;
38
39
const moduleTypes = {
40
+ // React
41
ISOMORPHIC: 'ISOMORPHIC',
42
+ // Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
43
RENDERER: 'RENDERER',
44
+ // Helper packages that access specific renderer's internals. (e.g. TestUtils)
45
RENDERER_UTILS: 'RENDERER_UTILS',
46
+ // Standalone reconciler for third-party renderers.
47
RECONCILER: 'RECONCILER',
48
+ // Non-Fiber implementations like SSR and Shallow renderers.
49
NON_FIBER_RENDERER: 'NON_FIBER_RENDERER',
50
};
51
45
-// React
46
-const ISOMORPHIC = moduleTypes.ISOMORPHIC;
47
-// Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
48
-const RENDERER = moduleTypes.RENDERER;
49
-// Helper packages that access specific renderer's internals. (e.g. TestUtils)
50
-const RENDERER_UTILS = moduleTypes.RENDERER_UTILS;
51
-// Standalone reconciler for third-party renderers.
52
-const RECONCILER = moduleTypes.RECONCILER;
53
-// Non-Fiber implementations like SSR and Shallow renderers.
54
-const NON_FIBER_RENDERER = moduleTypes.NON_FIBER_RENDERER;
52
+const {
53
+ ISOMORPHIC,
54
+ RENDERER,
55
+ RENDERER_UTILS,
56
+ RECONCILER,
57
+ NON_FIBER_RENDERER,
58
+} = moduleTypes;
59
60
const bundles = [
61
/******* Isomorphic *******/
@@ -150,7 +154,6 @@ const bundles = [
154
global: 'ReactDOMServer',
155
externals: ['react'],
156
},
153
-
157
{
158
bundleTypes: [NODE_DEV, NODE_PROD],
159
moduleType: NON_FIBER_RENDERER,
@@ -215,7 +218,6 @@ const bundles = [
218
'ReactNativeViewConfigRegistry',
219
],
220
},
218
-
221
{
222
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
223
moduleType: RENDERER,
@@ -256,7 +258,6 @@ const bundles = [
258
'ReactNativeViewConfigRegistry',
259
],
260
},
259
-
261
{
262
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
263
moduleType: RENDERER,
@@ -285,7 +286,6 @@ const bundles = [
286
global: 'ReactTestRenderer',
287
externals: ['react', 'scheduler', 'scheduler/unstable_mock'],
288
},
288
-
289
{
290
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
291
moduleType: NON_FIBER_RENDERER,
@@ -436,19 +436,16 @@ const bundles = [
436
437
/******* ESLint Plugin for Hooks (proposal) *******/
438
{
439
- // TODO: it's awkward to create a bundle for this
440
- // but if we don't, the package won't get copied.
441
- // We also can't create just DEV bundle because
442
- // it contains a NODE_ENV check inside.
443
- // We should probably tweak our build process
444
- // to allow "raw" packages that don't get bundled.
439
+ // TODO: it's awkward to create a bundle for this but if we don't, the package
440
+ // won't get copied. We also can't create just DEV bundle because it contains a
441
+ // NODE_ENV check inside. We should probably tweak our build process to allow
442
+ // "raw" packages that don't get bundled.
443
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV],
444
moduleType: ISOMORPHIC,
445
entry: 'eslint-plugin-react-hooks',
446
global: 'ESLintPluginReactHooks',
447
externals: [],
448
},
451
-
449
{
450
bundleTypes: [
451
FB_WWW_DEV,
@@ -588,6 +585,8 @@ function deepFreeze(o) {
585
586
// Don't accidentally mutate config as part of the build
587
deepFreeze(bundles);
588
+deepFreeze(bundleTypes);
589
+deepFreeze(moduleTypes);
590
591
module.exports = {
592
bundleTypes,