@samitouri / QOS-React-2 / commits / 7c802de797

[react-a11y] Add react-ui/accessibility to bundle build (#16804)

Dominic Gannaway committed Sep 17, 2019 at 20:22 UTC 7c802de797262dba582c8bf99e3793be75b5b73b
9 files changed +90 -7
packages/react-ui/accessibility/focus-table.js new
+12
@@ -0,0 +1,12 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +'use strict';
11 +
12 +module.exports = require('./src/FocusTable');
packages/react-ui/accessibility/src/FocusTable.js renamed
+1 -1
@@ -11,7 +11,7 @@ import type {ReactScopeMethods} from 'shared/ReactTypes';
11 import type {KeyboardEvent} from 'react-ui/events/keyboard';
12
13 import React from 'react';
14 -import {tabFocusableImpl} from './TabbableScope';
14 +import {tabFocusableImpl} from 'react-ui/accessibility/tabbable-scope';
15 import {useKeyboard} from 'react-ui/events/keyboard';
16
17 type FocusCellProps = {
packages/react-ui/accessibility/src/TabFocus.js renamed
+1 -1
@@ -11,7 +11,7 @@ import type {ReactScopeMethods} from 'shared/ReactTypes';
11 import type {KeyboardEvent} from 'react-ui/events/keyboard';
12
13 import React from 'react';
14 -import {TabbableScope} from './TabbableScope';
14 +import {TabbableScope} from 'react-ui/accessibility/tabbable-scope';
15 import {useKeyboard} from 'react-ui/events/keyboard';
16
17 type TabFocusControllerProps = {
packages/react-ui/accessibility/src/__tests__/FocusTable-test.internal.js renamed
+1 -1
@@ -19,7 +19,7 @@ describe('ReactFocusTable', () => {
19 ReactFeatureFlags = require('shared/ReactFeatureFlags');
20 ReactFeatureFlags.enableScopeAPI = true;
21 ReactFeatureFlags.enableFlareAPI = true;
22 - createFocusTable = require('../ReactFocusTable').createFocusTable;
22 + createFocusTable = require('../FocusTable').createFocusTable;
23 React = require('react');
24 });
25
packages/react-ui/accessibility/src/__tests__/TabFocus-test.internal.js renamed
+1 -1
@@ -20,7 +20,7 @@ describe('TabFocusController', () => {
20 ReactFeatureFlags = require('shared/ReactFeatureFlags');
21 ReactFeatureFlags.enableScopeAPI = true;
22 ReactFeatureFlags.enableFlareAPI = true;
23 - ReactTabFocus = require('../ReactTabFocus');
23 + ReactTabFocus = require('../TabFocus');
24 TabFocusController = ReactTabFocus.TabFocusController;
25 React = require('react');
26 });
packages/react-ui/accessibility/tab-focus.js new
+12
@@ -0,0 +1,12 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +'use strict';
11 +
12 +module.exports = require('./src/TabFocus');
packages/react-ui/accessibility/tabbable-scope.js new
+12
@@ -0,0 +1,12 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +'use strict';
11 +
12 +module.exports = require('./src/TabbableScope');
scripts/rollup/build.js
+9 -3
@@ -338,6 +338,8 @@ function getPlugins(
338 useForks(forks),
339 // Ensure we don't try to bundle any fbjs modules.
340 forbidFBJSImports(),
341 + // Replace any externals with their valid internal FB mappings
342 + isFBBundle && replace(Bundles.fbBundleExternalsMap),
343 // Use Node resolution mechanism.
344 resolve({
345 skip: externals,
@@ -452,11 +454,11 @@ async function createBundle(bundle, bundleType) {
454 const packageName = Packaging.getPackageName(bundle.entry);
455
456 let resolvedEntry = require.resolve(bundle.entry);
455 - if (
457 + const isFBBundle =
458 bundleType === FB_WWW_DEV ||
459 bundleType === FB_WWW_PROD ||
458 - bundleType === FB_WWW_PROFILING
459 - ) {
460 + bundleType === FB_WWW_PROFILING;
461 + if (isFBBundle) {
462 const resolvedFBEntry = resolvedEntry.replace('.js', '.fb.js');
463 if (fs.existsSync(resolvedFBEntry)) {
464 resolvedEntry = resolvedFBEntry;
@@ -473,6 +475,10 @@ async function createBundle(bundle, bundleType) {
475 const deps = Modules.getDependencies(bundleType, bundle.entry);
476 externals = externals.concat(deps);
477 }
478 + if (isFBBundle) {
479 + // Add any mapped fb bundle externals
480 + externals = externals.concat(Object.values(Bundles.fbBundleExternalsMap));
481 + }
482
483 const importSideEffects = Modules.getImportSideEffects();
484 const pureExternalModules = Object.keys(importSideEffects).filter(
scripts/rollup/bundles.js
+41
@@ -659,8 +659,48 @@ const bundles = [
659 global: 'ReactEventsTap',
660 externals: ['react'],
661 },
662 +
663 + // React UI - Accessibility
664 +
665 + {
666 + bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
667 + moduleType: NON_FIBER_RENDERER,
668 + entry: 'react-ui/accessibility/focus-table',
669 + global: 'ReactFocusTable',
670 + externals: [
671 + 'react',
672 + 'react-ui/events/keyboard',
673 + 'react-ui/accessibility/tabbable-scope',
674 + ],
675 + },
676 +
677 + {
678 + bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
679 + moduleType: NON_FIBER_RENDERER,
680 + entry: 'react-ui/accessibility/tab-focus',
681 + global: 'TabFocus',
682 + externals: [
683 + 'react',
684 + 'react-ui/events/keyboard',
685 + 'react-ui/accessibility/tabbable-scope',
686 + ],
687 + },
688 +
689 + {
690 + bundleTypes: [NODE_DEV, NODE_PROD, FB_WWW_DEV, FB_WWW_PROD],
691 + moduleType: NON_FIBER_RENDERER,
692 + entry: 'react-ui/accessibility/tabbable-scope',
693 + global: 'ReactTabbableScope',
694 + externals: ['react'],
695 + },
696 ];
697
698 +const fbBundleExternalsMap = {
699 + 'react-ui/events/keyboard': 'ReactEventsKeyboard',
700 + 'react-ui/events/tap': 'ReactEventsTap',
701 + 'react-ui/accessibility/tabbable-scope': 'ReactTabbableScope',
702 +};
703 +
704 // Based on deep-freeze by substack (public domain)
705 function deepFreeze(o) {
706 Object.freeze(o);
@@ -682,6 +722,7 @@ deepFreeze(bundleTypes);
722 deepFreeze(moduleTypes);
723
724 module.exports = {
725 + fbBundleExternalsMap,
726 bundleTypes,
727 moduleTypes,
728 bundles,