Proposed entry reorganization #328

Open
necolas opened this Issue Jan 11, 2017 · 2 comments

Projects

None yet

2 participants

@necolas
Owner
necolas commented Jan 11, 2017

index.js - removes all native modules and components (e.g. NativeModules, BackAndroid)
core.js - remains unchanged
compat.js - RN-compatible exports (i.e., includes NativeModules, BackAndroid stubs)

Why? React Native is not currently designed to extend beyond Android/iOS. It exports platform-specific modules, native-specific modules, and includes platform-specific styles and props in many places. This proposal is an initial step towards a platform-agnostic library (index.js), while retaining/adding wider RN compatible for people trying to run existing RN code on Web (compat.js), and supporting contemporary ES5-bundlers and web migrations with a simplified core (core.js).

Users would alias react-native to one of the 3 entry files. For example, mobile.twitter.com could initially alias to core.js and eventually index.js once an ES6 export is available (to enable tree-shaking). An app depending on OSS RN packages that assume only iOS/Android platforms (and import platform-specific modules from RN) could alias react-native to compat.js until RN's exports and the wider ecosystem are more platform-agnostic.

@necolas necolas added the enhancement label Jan 11, 2017
@MoOx
Contributor
MoOx commented Jan 13, 2017

This make sense.
Just one question: what are the argument for something to be in core or in the index? Eg: Dimensions seems to be a core module to me - I guess I just miss something :)

@necolas
Owner
necolas commented Jan 13, 2017

If an API/component is a dependency of the basic building blocks in core, it could be added to core. At the moment Dimensions is not and isn't needed to build components in most cases, whereas Image, View, Text and StyleSheet are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment