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
Lazy import RN components #617
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
osdnk
approved these changes
May 29, 2019
kmagiera
added a commit
that referenced
this pull request
May 29, 2019
This PR changes the way we export gesture-handler-wrapped components. Instead of importing them from RN we rely on lazy-load mechanism (that is also utilize in RN core) to only pull in core components that we need. On top of that I added memoization mechanism such that for each component only one wrapper component is created. This change makes GH more future proof as some core components (e.g. AndroidToolbar) are being removed from react-native. This will allow consumers to keep using these so long they rely on RN version that have them included (full backward compatibility). And also allow for consumers relying on new RN versions to wrap components from react-native-community github in case they want to continue using these.
This breaks tree-shaking on web, and with strict configs like expo, it breaks altogether when you use import/export and module.exports. |
EvanBacon
reviewed
Jun 1, 2019
Platform, | ||
processColor, | ||
default as ReactNative, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will include everything in React Native which means things like react-art which aren't used by anyone will get bundled.
kmagiera
pushed a commit
that referenced
this pull request
Jun 1, 2019
# Why Default import was removed from react-native-web. necolas/react-native-web#1277 The use of module.exports and import/export breaks tree-shaking in with babel-preset-expo. Related: #617 Fixes: expo/expo#4339 # How * Moved the shims to `Gestures(.web).js` * Moved all modules out of main re-export file. (optional)
janicduplessis
pushed a commit
to janicduplessis/react-native-gesture-handler
that referenced
this pull request
Feb 16, 2020
This PR changes the way we export gesture-handler-wrapped components. Instead of importing them from RN we rely on lazy-load mechanism (that is also utilize in RN core) to only pull in core components that we need. On top of that I added memoization mechanism such that for each component only one wrapper component is created. This change makes GH more future proof as some core components (e.g. AndroidToolbar) are being removed from react-native. This will allow consumers to keep using these so long they rely on RN version that have them included (full backward compatibility). And also allow for consumers relying on new RN versions to wrap components from react-native-community github in case they want to continue using these.
janicduplessis
pushed a commit
to janicduplessis/react-native-gesture-handler
that referenced
this pull request
Feb 16, 2020
# Why Default import was removed from react-native-web. necolas/react-native-web#1277 The use of module.exports and import/export breaks tree-shaking in with babel-preset-expo. Related: software-mansion#617 Fixes: expo/expo#4339 # How * Moved the shims to `Gestures(.web).js` * Moved all modules out of main re-export file. (optional)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the way we export gesture-handler-wrapped components. Instead of importing them from RN we rely on lazy-load mechanism (that is also utilize in RN core) to only pull in core components that we need. On top of that I added memoization mechanism such that for each component only one wrapper component is created.
This change makes GH more future proof as some core components (e.g. AndroidToolbar) are being removed from react-native. This will allow consumers to keep using these so long they rely on RN version that have them included (full backward compatibility). And also allow for consumers relying on new RN versions to wrap components from react-native-community github in case they want to continue using these.