From c530639dd21543ab8d7d9e83d53197cda234b26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kunuk=20Nykj=C3=A6r?= Date: Thu, 25 Apr 2019 17:24:01 +0200 Subject: [PATCH] Minor code structure adjustments to the bundles.js file (#15079) * simplify * fix error * use deepFreeze * move comments --- scripts/rollup/bundles.js | 71 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index fddd076889fda..6381514e9fc7d 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -18,40 +18,44 @@ const bundleTypes = { RN_FB_PROFILING: 'RN_FB_PROFILING', }; -const UMD_DEV = bundleTypes.UMD_DEV; -const UMD_PROD = bundleTypes.UMD_PROD; -const UMD_PROFILING = bundleTypes.UMD_PROFILING; -const NODE_DEV = bundleTypes.NODE_DEV; -const NODE_PROD = bundleTypes.NODE_PROD; -const NODE_PROFILING = bundleTypes.NODE_PROFILING; -const FB_WWW_DEV = bundleTypes.FB_WWW_DEV; -const FB_WWW_PROD = bundleTypes.FB_WWW_PROD; -const FB_WWW_PROFILING = bundleTypes.FB_WWW_PROFILING; -const RN_OSS_DEV = bundleTypes.RN_OSS_DEV; -const RN_OSS_PROD = bundleTypes.RN_OSS_PROD; -const RN_OSS_PROFILING = bundleTypes.RN_OSS_PROFILING; -const RN_FB_DEV = bundleTypes.RN_FB_DEV; -const RN_FB_PROD = bundleTypes.RN_FB_PROD; -const RN_FB_PROFILING = bundleTypes.RN_FB_PROFILING; +const { + UMD_DEV, + UMD_PROD, + UMD_PROFILING, + NODE_DEV, + NODE_PROD, + NODE_PROFILING, + FB_WWW_DEV, + FB_WWW_PROD, + FB_WWW_PROFILING, + RN_OSS_DEV, + RN_OSS_PROD, + RN_OSS_PROFILING, + RN_FB_DEV, + RN_FB_PROD, + RN_FB_PROFILING, +} = bundleTypes; const moduleTypes = { + // React ISOMORPHIC: 'ISOMORPHIC', + // Individual renderers. They bundle the reconciler. (e.g. ReactDOM) RENDERER: 'RENDERER', + // Helper packages that access specific renderer's internals. (e.g. TestUtils) RENDERER_UTILS: 'RENDERER_UTILS', + // Standalone reconciler for third-party renderers. RECONCILER: 'RECONCILER', + // Non-Fiber implementations like SSR and Shallow renderers. NON_FIBER_RENDERER: 'NON_FIBER_RENDERER', }; -// React -const ISOMORPHIC = moduleTypes.ISOMORPHIC; -// Individual renderers. They bundle the reconciler. (e.g. ReactDOM) -const RENDERER = moduleTypes.RENDERER; -// Helper packages that access specific renderer's internals. (e.g. TestUtils) -const RENDERER_UTILS = moduleTypes.RENDERER_UTILS; -// Standalone reconciler for third-party renderers. -const RECONCILER = moduleTypes.RECONCILER; -// Non-Fiber implementations like SSR and Shallow renderers. -const NON_FIBER_RENDERER = moduleTypes.NON_FIBER_RENDERER; +const { + ISOMORPHIC, + RENDERER, + RENDERER_UTILS, + RECONCILER, + NON_FIBER_RENDERER, +} = moduleTypes; const bundles = [ /******* Isomorphic *******/ @@ -150,7 +154,6 @@ const bundles = [ global: 'ReactDOMServer', externals: ['react'], }, - { bundleTypes: [NODE_DEV, NODE_PROD], moduleType: NON_FIBER_RENDERER, @@ -215,7 +218,6 @@ const bundles = [ 'ReactNativeViewConfigRegistry', ], }, - { bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, @@ -256,7 +258,6 @@ const bundles = [ 'ReactNativeViewConfigRegistry', ], }, - { bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, @@ -285,7 +286,6 @@ const bundles = [ global: 'ReactTestRenderer', externals: ['react', 'scheduler', 'scheduler/unstable_mock'], }, - { bundleTypes: [FB_WWW_DEV, NODE_DEV, NODE_PROD, UMD_DEV, UMD_PROD], moduleType: NON_FIBER_RENDERER, @@ -436,19 +436,16 @@ const bundles = [ /******* ESLint Plugin for Hooks (proposal) *******/ { - // TODO: it's awkward to create a bundle for this - // but if we don't, the package won't get copied. - // We also can't create just DEV bundle because - // it contains a NODE_ENV check inside. - // We should probably tweak our build process - // to allow "raw" packages that don't get bundled. + // TODO: it's awkward to create a bundle for this but if we don't, the package + // won't get copied. We also can't create just DEV bundle because it contains a + // NODE_ENV check inside. We should probably tweak our build process to allow + // "raw" packages that don't get bundled. bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV], moduleType: ISOMORPHIC, entry: 'eslint-plugin-react-hooks', global: 'ESLintPluginReactHooks', externals: [], }, - { bundleTypes: [ FB_WWW_DEV, @@ -588,6 +585,8 @@ function deepFreeze(o) { // Don't accidentally mutate config as part of the build deepFreeze(bundles); +deepFreeze(bundleTypes); +deepFreeze(moduleTypes); module.exports = { bundleTypes,