Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default import #1258

Closed
EvanBacon opened this issue Feb 26, 2019 · 0 comments
Closed

Remove default import #1258

EvanBacon opened this issue Feb 26, 2019 · 0 comments
Milestone

Comments

@EvanBacon
Copy link
Contributor

EvanBacon commented Feb 26, 2019

Is your feature request related to a problem? Please describe.

AFAICT you cannot shake the default export, even if it is not included in your project.
Repro: Basic Treeshaking
Just removing react-art saves 143kb (non-gzip).

Also noting that in an RNWeb project, omitting the library react-art does not build: Issue

Describe a solution you'd like

@ide has opened a PR to remove the default import from React Native proper facebook/metro#362

We could then delete:

const ReactNative = {
// top-level API
createElement,
findNodeHandle,
render,
unmountComponentAtNode,
// modules
processColor,
NativeModules,
TextPropTypes,
ViewPropTypes,
// APIs
AccessibilityInfo,
Alert,
Animated,
AppRegistry,
AppState,
AsyncStorage,
BackHandler,
Clipboard,
DeviceInfo,
Dimensions,
Easing,
I18nManager,
InteractionManager,
Keyboard,
LayoutAnimation,
Linking,
NativeEventEmitter,
NetInfo,
PanResponder,
PixelRatio,
Platform,
Share,
StyleSheet,
UIManager,
Vibration,
// components
ActivityIndicator,
ART,
Button,
CheckBox,
FlatList,
Image,
ImageBackground,
KeyboardAvoidingView,
ListView,
Modal,
Picker,
ProgressBar,
RefreshControl,
SafeAreaView,
ScrollView,
SectionList,
Slider,
StatusBar,
SwipeableFlatList,
SwipeableListView,
Switch,
Text,
TextInput,
Touchable,
TouchableHighlight,
TouchableNativeFeedback,
TouchableOpacity,
TouchableWithoutFeedback,
View,
VirtualizedList,
YellowBox,
// propTypes
ColorPropType,
EdgeInsetsPropType,
PointPropType,
// compat (components)
DatePickerIOS,
DrawerLayoutAndroid,
ImageEditor,
ImageStore,
InputAccessoryView,
MaskedViewIOS,
NavigatorIOS,
PickerIOS,
ProgressBarAndroid,
ProgressViewIOS,
SegmentedControlIOS,
SnapshotViewIOS,
TabBarIOS,
ToastAndroid,
ToolbarAndroid,
ViewPagerAndroid,
WebView,
// compat (apis)
ActionSheetIOS,
AlertIOS,
CameraRoll,
DatePickerAndroid,
ImagePickerIOS,
PermissionsAndroid,
PushNotificationIOS,
Settings,
StatusBarIOS,
Systrace,
TimePickerAndroid,
TVEventHandler,
VibrationIOS
};
export default ReactNative;

Describe alternatives you've considered

  • Use a plugin like deep-scope-analysis which will remove the default if there are absolutely no module.exports/requires. Unfortunately this means that react-art would still get bundled (amongst others).

Additional context

N/A

@EvanBacon EvanBacon changed the title Remove umbrella import Remove default import Feb 26, 2019
@necolas necolas added this to the 0.11.0 milestone Mar 8, 2019
necolas added a commit that referenced this issue Mar 8, 2019
Remove the default export that was provided for compatibility with legacy
imports of React Native CommonJS modules. These patterns is no longer
supported:

```
import ReactNative from 'react-native';
const ReactNative = require('react-native');
```

Fix #1258
@necolas necolas added the has-PR label Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants