Skip to content

Commit

Permalink
Minor code structure adjustments to the bundles.js file (#15079)
Browse files Browse the repository at this point in the history
* simplify

* fix error

* use deepFreeze

* move comments
  • Loading branch information
kunukn authored and cpojer committed Apr 25, 2019
1 parent ed36df4 commit c530639
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 *******/
Expand Down Expand Up @@ -150,7 +154,6 @@ const bundles = [
global: 'ReactDOMServer',
externals: ['react'],
},

{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: NON_FIBER_RENDERER,
Expand Down Expand Up @@ -215,7 +218,6 @@ const bundles = [
'ReactNativeViewConfigRegistry',
],
},

{
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
moduleType: RENDERER,
Expand Down Expand Up @@ -256,7 +258,6 @@ const bundles = [
'ReactNativeViewConfigRegistry',
],
},

{
bundleTypes: [RN_OSS_DEV, RN_OSS_PROD, RN_OSS_PROFILING],
moduleType: RENDERER,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c530639

Please sign in to comment.