Skip to content

Commit c530639

Browse files
kunukncpojer
authored andcommitted
Minor code structure adjustments to the bundles.js file (#15079)
* simplify * fix error * use deepFreeze * move comments
1 parent ed36df4 commit c530639

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

scripts/rollup/bundles.js

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,44 @@ const bundleTypes = {
1818
RN_FB_PROFILING: 'RN_FB_PROFILING',
1919
};
2020

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;
3638

3739
const moduleTypes = {
40+
// React
3841
ISOMORPHIC: 'ISOMORPHIC',
42+
// Individual renderers. They bundle the reconciler. (e.g. ReactDOM)
3943
RENDERER: 'RENDERER',
44+
// Helper packages that access specific renderer's internals. (e.g. TestUtils)
4045
RENDERER_UTILS: 'RENDERER_UTILS',
46+
// Standalone reconciler for third-party renderers.
4147
RECONCILER: 'RECONCILER',
48+
// Non-Fiber implementations like SSR and Shallow renderers.
4249
NON_FIBER_RENDERER: 'NON_FIBER_RENDERER',
4350
};
4451

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;
5559

5660
const bundles = [
5761
/******* Isomorphic *******/
@@ -150,7 +154,6 @@ const bundles = [
150154
global: 'ReactDOMServer',
151155
externals: ['react'],
152156
},
153-
154157
{
155158
bundleTypes: [NODE_DEV, NODE_PROD],
156159
moduleType: NON_FIBER_RENDERER,
@@ -215,7 +218,6 @@ const bundles = [
215218
'ReactNativeViewConfigRegistry',
216219
],
217220
},
218-
219221
{
220222
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
221223
moduleType: RENDERER,
@@ -256,7 +258,6 @@ const bundles = [
256258
'ReactNativeViewConfigRegistry',
257259
],
258260
},
259-
260261
{
261262
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
262263
moduleType: RENDERER,
@@ -285,7 +286,6 @@ const bundles = [
285286
global: 'ReactTestRenderer',
286287
externals: ['react', 'scheduler', 'scheduler/unstable_mock'],
287288
},
288-
289289
{
290290
bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD],
291291
moduleType: NON_FIBER_RENDERER,
@@ -436,19 +436,16 @@ const bundles = [
436436

437437
/******* ESLint Plugin for Hooks (proposal) *******/
438438
{
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.
445443
bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV],
446444
moduleType: ISOMORPHIC,
447445
entry: 'eslint-plugin-react-hooks',
448446
global: 'ESLintPluginReactHooks',
449447
externals: [],
450448
},
451-
452449
{
453450
bundleTypes: [
454451
FB_WWW_DEV,
@@ -588,6 +585,8 @@ function deepFreeze(o) {
588585

589586
// Don't accidentally mutate config as part of the build
590587
deepFreeze(bundles);
588+
deepFreeze(bundleTypes);
589+
deepFreeze(moduleTypes);
591590

592591
module.exports = {
593592
bundleTypes,

0 commit comments

Comments
 (0)