Skip to content

Conversation

@kmagiera
Copy link
Member

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.

@kmagiera kmagiera requested a review from osdnk May 29, 2019 19:04
@kmagiera kmagiera merged commit f4b2c79 into master May 29, 2019
@kmagiera kmagiera deleted the lazyimport branch May 29, 2019 19:17
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.
@EvanBacon
Copy link
Contributor

This breaks tree-shaking on web, and with strict configs like expo, it breaks altogether when you use import/export and module.exports.

FlatList,
Platform,
processColor,
default as ReactNative,
Copy link
Contributor

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)
enigmaticsoul216 added a commit to enigmaticsoul216/RN_gesture_handler that referenced this pull request Feb 3, 2025
# 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/react-native-gesture-handler#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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants