[change] 'react-native-web' module organization and exports

The patch reorganizes the top-level module division of the
'react-native-web' project.

Previously, the package's exported modules were found in:

    apis/*/index.js
    components/*/index.js
    components/*/*.js
    modules/*/index.js
    propTypes/*.js

Now, each part of the exported API is found in:

    exports/*/index.js

And anything not directly part of the exported API is found in:

    modules/*/index.js
    vendor/*/index.js

Close #748
This commit is contained in:
Nicolas Gallagher
2018-01-01 14:12:30 -08:00
parent 209bd3aee1
commit 87fdd6c73b
170 changed files with 303 additions and 393 deletions
@@ -7,11 +7,11 @@ export { ColorPropType, StyleSheet, Text, createElement } from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
export { default as View } from 'react-native-web/dist/components/View';
export { default as ColorPropType } from 'react-native-web/dist/propTypes/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/apis/StyleSheet';
export { default as Text } from 'react-native-web/dist/components/Text';
export { default as createElement } from 'react-native-web/dist/modules/createElement';
export { default as View } from 'react-native-web/dist/exports/View';
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
export { default as Text } from 'react-native-web/dist/exports/Text';
export { default as createElement } from 'react-native-web/dist/exports/createElement';
"
`;
@@ -22,11 +22,11 @@ export { ColorPropType, StyleSheet, Text, createElement } from 'react-native-web
↓ ↓ ↓ ↓ ↓ ↓
export { default as View } from 'react-native-web/dist/components/View';
export { default as ColorPropType } from 'react-native-web/dist/propTypes/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/apis/StyleSheet';
export { default as Text } from 'react-native-web/dist/components/Text';
export { default as createElement } from 'react-native-web/dist/modules/createElement';
export { default as View } from 'react-native-web/dist/exports/View';
export { default as ColorPropType } from 'react-native-web/dist/exports/ColorPropType';
export { default as StyleSheet } from 'react-native-web/dist/exports/StyleSheet';
export { default as Text } from 'react-native-web/dist/exports/Text';
export { default as createElement } from 'react-native-web/dist/exports/createElement';
"
`;
@@ -40,10 +40,10 @@ import * as ReactNativeModules from 'react-native';
↓ ↓ ↓ ↓ ↓ ↓
import ReactNative from 'react-native-web/dist/index';
import View from 'react-native-web/dist/components/View';
import { Invalid } from 'react-native-web/dist/index';
import MyView from 'react-native-web/dist/components/View';
import ViewPropTypes from 'react-native-web/dist/components/View/ViewPropTypes';
import View from 'react-native-web/dist/exports/View';
import Invalid from 'react-native-web/dist/exports/Invalid';
import MyView from 'react-native-web/dist/exports/View';
import ViewPropTypes from 'react-native-web/dist/exports/ViewPropTypes';
import * as ReactNativeModules from 'react-native-web/dist/index';
"
`;
@@ -56,12 +56,12 @@ import * as ReactNativeModules from 'react-native-web';
↓ ↓ ↓ ↓ ↓ ↓
import createElement from 'react-native-web/dist/modules/createElement';
import ColorPropType from 'react-native-web/dist/propTypes/ColorPropType';
import StyleSheet from 'react-native-web/dist/apis/StyleSheet';
import View from 'react-native-web/dist/components/View';
import TouchableOpacity from 'react-native-web/dist/components/Touchable/TouchableOpacity';
import processColor from 'react-native-web/dist/modules/processColor';
import createElement from 'react-native-web/dist/exports/createElement';
import ColorPropType from 'react-native-web/dist/exports/ColorPropType';
import StyleSheet from 'react-native-web/dist/exports/StyleSheet';
import View from 'react-native-web/dist/exports/View';
import TouchableOpacity from 'react-native-web/dist/exports/TouchableOpacity';
import processColor from 'react-native-web/dist/exports/processColor';
import * as ReactNativeModules from 'react-native-web/dist/index';
"
`;
@@ -76,16 +76,16 @@ const { ColorPropType, StyleSheet, View, TouchableOpacity, processColor } = requ
const ReactNative = require('react-native-web');
const createElement = require('react-native-web/dist/modules/createElement');
const createElement = require('react-native-web/dist/exports/createElement');
const ColorPropType = require('react-native-web/dist/propTypes/ColorPropType');
const ColorPropType = require('react-native-web/dist/exports/ColorPropType');
const StyleSheet = require('react-native-web/dist/apis/StyleSheet');
const StyleSheet = require('react-native-web/dist/exports/StyleSheet');
const View = require('react-native-web/dist/components/View');
const View = require('react-native-web/dist/exports/View');
const TouchableOpacity = require('react-native-web/dist/components/Touchable/TouchableOpacity');
const TouchableOpacity = require('react-native-web/dist/exports/TouchableOpacity');
const processColor = require('react-native-web/dist/modules/processColor');
const processColor = require('react-native-web/dist/exports/processColor');
"
`;
@@ -1,89 +1,5 @@
const getDistLocation = importName => {
const root = 'react-native-web/dist';
switch (importName) {
// apis
case 'Animated':
case 'AppRegistry':
case 'AppState':
case 'AsyncStorage':
case 'BackHandler':
case 'Clipboard':
case 'Dimensions':
case 'Easing':
case 'I18nManager':
case 'InteractionManager':
case 'Keyboard':
case 'Linking':
case 'NetInfo':
case 'PanResponder':
case 'PixelRatio':
case 'Platform':
case 'StyleSheet':
case 'UIManager':
case 'Vibration': {
return `${root}/apis/${importName}`;
}
// components
case 'ActivityIndicator':
case 'ART':
case 'Button':
case 'FlatList':
case 'Image':
case 'KeyboardAvoidingView':
case 'ListView':
case 'Modal':
case 'Picker':
case 'ProgressBar':
case 'RefreshControl':
case 'ScrollView':
case 'SectionList':
case 'Slider':
case 'StatusBar':
case 'Switch':
case 'Text':
case 'TextInput':
case 'View':
case 'VirtualizedList': {
return `${root}/components/${importName}`;
}
case 'Touchable':
case 'TouchableHighlight':
case 'TouchableNativeFeedback':
case 'TouchableOpacity':
case 'TouchableWithoutFeedback': {
return `${root}/components/Touchable/${importName}`;
}
// modules
case 'createElement':
case 'findNodeHandle':
case 'NativeModules':
case 'processColor':
case 'render':
case 'unmountComponentAtNode': {
return `${root}/modules/${importName}`;
}
// propTypes
case 'ColorPropType':
case 'EdgeInsetsPropType':
case 'PointPropType': {
return `${root}/propTypes/${importName}`;
}
case 'TextPropTypes': {
return `${root}/components/Text/${importName}`;
}
case 'ViewPropTypes': {
return `${root}/components/View/${importName}`;
}
default:
return;
}
};
const getDistLocation = importName =>
importName ? `react-native-web/dist/exports/${importName}` : undefined;
const isReactNativeRequire = (t, node) => {
const { declarations } = node;