From 9d3c6d66b41c43a4f2b504534cc119a7e193915e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kunuk=20Nykj=C3=A6r?= Date: Sun, 10 Mar 2019 16:37:50 +0100 Subject: [PATCH 1/4] simplify --- scripts/rollup/bundles.js | 67 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 16bd645e768..9a845edaa44 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -18,21 +18,23 @@ 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 = { ISOMORPHIC: 'ISOMORPHIC', @@ -43,15 +45,17 @@ const moduleTypes = { }; // 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, + // Individual renderers. They bundle the reconciler. (e.g. ReactDOM) + RENDERER = moduleTypes, + // Helper packages that access specific renderer's internals. (e.g. TestUtils) + RENDERER_UTILS, + // Standalone reconciler for third-party renderers. + RECONCILER, + // Non-Fiber implementations like SSR and Shallow renderers. + 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, @@ -214,7 +217,6 @@ const bundles = [ 'ReactNativeViewConfigRegistry', ], }, - { bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, @@ -254,7 +256,6 @@ const bundles = [ 'ReactNativeViewConfigRegistry', ], }, - { bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING], moduleType: RENDERER, @@ -283,7 +284,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, @@ -434,19 +434,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, From fbb4ca1c26b5ecd1f97defcd2e51c5b9ccb4de34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kunuk=20Nykj=C3=A6r?= Date: Sun, 10 Mar 2019 16:40:43 +0100 Subject: [PATCH 2/4] fix error --- scripts/rollup/bundles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 9a845edaa44..1f98ea8aa00 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -48,7 +48,7 @@ const moduleTypes = { const { ISOMORPHIC, // Individual renderers. They bundle the reconciler. (e.g. ReactDOM) - RENDERER = moduleTypes, + RENDERER, // Helper packages that access specific renderer's internals. (e.g. TestUtils) RENDERER_UTILS, // Standalone reconciler for third-party renderers. From 6c6173990b6f61f760c7a1f68333b628fb69c428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kunuk=20Nykj=C3=A6r?= Date: Sun, 10 Mar 2019 21:30:05 +0100 Subject: [PATCH 3/4] use deepFreeze --- scripts/rollup/bundles.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 1f98ea8aa00..36b53d31174 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -17,6 +17,7 @@ const bundleTypes = { RN_FB_PROD: 'RN_FB_PROD', RN_FB_PROFILING: 'RN_FB_PROFILING', }; +deepFreeze(bundleTypes); const { UMD_DEV, @@ -43,9 +44,10 @@ const moduleTypes = { RECONCILER: 'RECONCILER', NON_FIBER_RENDERER: 'NON_FIBER_RENDERER', }; +deepFreeze(moduleTypes); -// React const { + // React ISOMORPHIC, // Individual renderers. They bundle the reconciler. (e.g. ReactDOM) RENDERER, From aca3eb83ec121768ab0b8586cd2b18ef4824ca5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kunuk=20Nykj=C3=A6r?= Date: Sun, 10 Mar 2019 21:35:03 +0100 Subject: [PATCH 4/4] move comments --- scripts/rollup/bundles.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/rollup/bundles.js b/scripts/rollup/bundles.js index 36b53d31174..ccd143ec410 100644 --- a/scripts/rollup/bundles.js +++ b/scripts/rollup/bundles.js @@ -17,7 +17,6 @@ const bundleTypes = { RN_FB_PROD: 'RN_FB_PROD', RN_FB_PROFILING: 'RN_FB_PROFILING', }; -deepFreeze(bundleTypes); const { UMD_DEV, @@ -38,24 +37,23 @@ const { } = 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', }; -deepFreeze(moduleTypes); const { - // React ISOMORPHIC, - // Individual renderers. They bundle the reconciler. (e.g. ReactDOM) RENDERER, - // Helper packages that access specific renderer's internals. (e.g. TestUtils) RENDERER_UTILS, - // Standalone reconciler for third-party renderers. RECONCILER, - // Non-Fiber implementations like SSR and Shallow renderers. NON_FIBER_RENDERER, } = moduleTypes; @@ -479,6 +477,8 @@ function deepFreeze(o) { // Don't accidentally mutate config as part of the build deepFreeze(bundles); +deepFreeze(bundleTypes); +deepFreeze(moduleTypes); module.exports = { bundleTypes,