-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
fix: bind scope to null to prevent issues with inline requires #2972
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
1 task
m-bert
approved these changes
Jul 2, 2024
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.
Hi @EvanBacon! Thanks for this PR. I took the liberty of fixing prettier since I didn't want to bother you 😅
EvanBacon
added a commit
to expo/expo
that referenced
this pull request
Jul 23, 2024
# Why > Most of the original PR has been landed in #30417 - Metro bundler does not have any form of graph-wide tree shaking built-in. This can lead to bundle sizes that are larger than they need to be, especially in the case of icon libraries. - This PR (which is partially an RFC) aims to add a system for removing unused imports and exports from a production bundle. <!-- Please describe the motivation for this PR, and link to relevant GitHub issues, forums posts, or feature requests. --> # How - Leverage the new "optimize graph" mode to perform holistic optimizations in the serializer. #30417 - Tree shaking can be enabled with the new env var `EXPO_UNSTABLE_TREE_SHAKING=1`. - This PR also adds a "barrel expansion" system which attempts to replace `export * from '...'` statements with `export { View, Image, etc } from '...'` statements to enable more graph reduction. - Empty modules (containing only comments and directives) are removed from the bundle. - Side-effecty imports (imports with zero specifiers, `import "foo"` and `import {} from "foo"`) are preserved unless marked otherwise by a `package.json`'s `sideEffects` field. - Custom imports such as `require.context` and `require.resolveWeak` are left in place. - Removed exports with source will trigger a recrawl to ensure any new unused imports/exports are recursively removed. - The feature is artificially forced to only run when `EXPO_UNSTABLE_TREE_SHAKING=1` is set, and when bundling for production. Tree shaking is disabled for SSR bundles. I may expand this to be web-only too just due to a lack of continuous testing for native runtimes. - Added some external fixes software-mansion/react-native-reanimated#6171 #30010 #29980 #29964 #29963 software-mansion/react-native-gesture-handler#2972 # Further work Some ideas that I've had but aren't implemented in this PR: - Use the worker farm to parallelize transformation in the serializer. This could be tricky because we'd need to convert the AST to a serial format then re-parse it back. - ~~Fork collectDependencies to fully track the import/exports so we can reuse the same import crawling code and references. This would also speed up the bundling as we could parallelize and cache the pass.~~ #30140 - Use a totally custom syntax for matching import/exports, e.g. `_$$_IMPORT_DEFAULT, _$$_IMPORT_ALL` (and some new export equivalents) to reduce the number of transforms we run in the serializer. All import/export's and the iife wrap could be run at transform-time and we'd simply be mutating a valid JS bundle in the serializer. This would be very challenging though and make it harder for users to contribute to the implementation. - ~~Upstream the hack on transformSyncRequire to support require.context with one parameter. facebook/metro#1129 - Detect if a module is CJS according to Node.js heuristic, e.g. `.cjs`, package exports, etc. then opt it out of tree shaking. - [ ] update source maps # Test Plan - Added an e2e tree shaking test for web. - Added mini-metro tests to account for the known and expected tree shaking behaviors. - Added mini-metro tests for side-effect handling (need more here). - Ensured all apps in expo/apps can be transformed and run with tree shaking enabled. --------- Co-authored-by: Expo Bot <[email protected]> Co-authored-by: Aman Mittal <[email protected]>
github-merge-queue bot
referenced
this pull request
in valora-inc/wallet
Aug 6, 2024
…5714) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [react-native-gesture-handler](https://togithub.com/software-mansion/react-native-gesture-handler) | [`^2.17.1` -> `^2.18.1`](https://renovatebot.com/diffs/npm/react-native-gesture-handler/2.17.1/2.18.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-gesture-handler/2.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-gesture-handler/2.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-gesture-handler/2.17.1/2.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-gesture-handler/2.17.1/2.18.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>software-mansion/react-native-gesture-handler (react-native-gesture-handler)</summary> ### [`v2.18.1`](https://togithub.com/software-mansion/react-native-gesture-handler/releases/tag/2.18.1) [Compare Source](https://togithub.com/software-mansion/react-native-gesture-handler/compare/2.18.0...2.18.1) #### 🐛 Bug fixes - Fix build on RN 0.74 by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3024](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3024) #### What's Changed - Bump ws from 6.2.2 to 6.2.3 in /example by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3003](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3003) - Bump requirejs from 2.3.6 to 2.3.7 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3009](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3009) - Bump fast-xml-parser from 4.2.5 to 4.4.1 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3016](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3016) - Bump ws from 6.2.2 to 6.2.3 in /docs by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3021](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3021) - Add documentation page for `Pressable` component by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2992](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2992) - Add docs page for Reanimated Swipeable by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2962](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2962) **Full Changelog**: software-mansion/react-native-gesture-handler@2.18.0...2.18.1 ### [`v2.18.0`](https://togithub.com/software-mansion/react-native-gesture-handler/releases/tag/2.18.0) [Compare Source](https://togithub.com/software-mansion/react-native-gesture-handler/compare/2.17.1...2.18.0) #### ❗ Important changes - Create a separate component out of the new Swipeable row by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2936](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2936) - Create gesturized pressable component by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2942](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2942), [https://github.com/software-mansion/react-native-gesture-handler/pull/2977](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2977), [https://github.com/software-mansion/react-native-gesture-handler/pull/2982](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2982), [https://github.com/software-mansion/react-native-gesture-handler/pull/2981](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2981) - Support for React Native 0.75 by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2966](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2966) #### 👍 Improvements - \[macOS] Add `ForceTouch` warning by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2954](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2954) - Remove shared value read on the JS thread during detector update by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2957](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2957) - Use a newer constructor for all Gesture Handler events on Android by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2967](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2967) - Persist rotation and pinch gesture through pointer changes on android by [@​coado](https://togithub.com/coado) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2983](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2983) - \[macOS] Add `NativeViewGestureHandler` by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3004](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3004) - Add `enabled` prop support to swipeable by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3011](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3011) #### 🐛 Bug fixes - Make handler comparator work only on non-null objects by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2964](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2964) - fix: bind scope to null to prevent issues with inline requires by [@​EvanBacon](https://togithub.com/EvanBacon) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2972](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2972) - Replace `queueMicrotask` with `requestAnimationFrame` by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2969](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2969) - Resolve circular dependencies on JS side by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2970](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2970) - Fix Android native buttons emitting 2 press events when talkback is enabled by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3002](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3002) - Fix `ScrollView` intercepting touches through out-of-bounds children by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3017](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3017) - Change `onPress` argument in buttons by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3006](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3006) - \[macOS] Fix handlers not responding after opening context menu by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3008](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3008) - \[iOS | macOS] Fix translation calculation in `LongPress` by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3013](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3013) - Fix cancelling manual activation gestures blocking interactivity on iOS by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3007](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3007) #### 🔢 Miscellaneous - Bump ws from 6.2.2 to 6.2.3 in /FabricExample by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2949](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2949) - Bump braces from 3.0.2 to 3.0.3 in /MacOSExample by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2956](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2956) - docs: bump `@swmansion/t-rex-ui` to 0.0.12 by [@​patrycjakalinska](https://togithub.com/patrycjakalinska) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2958](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2958) - Bump braces from 3.0.2 to 3.0.3 in /FabricExample by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2965](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2965) - Set consistent prettier version across all package.jsons by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2971](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2971) - Change naming scheme in package.json from camelCase to dash-case by [@​latekvo](https://togithub.com/latekvo) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2973](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2973) - Unify comments and simplify some conditions. by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2984](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2984) - docs: Update Expo installation instructions by [@​amandeepmittal](https://togithub.com/amandeepmittal) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2991](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2991) - Bump fast-loops from 1.1.3 to 1.1.4 in /docs by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2986](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2986) - Remove plural form in docs by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2995](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2995) - Bump fast-loops from 1.1.3 to 1.1.4 in /example by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2994](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2994) - Don't run old arch integrity check on every PR by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2998](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2998) - docs: fix footer on landing by [@​patrycjakalinska](https://togithub.com/patrycjakalinska) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2997](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2997) - docs: Replace HireUsSection with `@swmansion/t-rex-ui` component by [@​patrycjakalinska](https://togithub.com/patrycjakalinska) in [https://github.com/software-mansion/react-native-gesture-handler/pull/2996](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2996) - Mention `drawerWillShow` in `DrawerLayout` docs by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3000](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3000) - chore: Refactor gradle task to JS scripts by [@​maciekstosio](https://togithub.com/maciekstosio) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3001](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3001) - Update dependencies related to tests by [@​j-piasecki](https://togithub.com/j-piasecki) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3005](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3005) - \[macOS] Switch `hasPointerInside` to `containsPointInView` by [@​m-bert](https://togithub.com/m-bert) in [https://github.com/software-mansion/react-native-gesture-handler/pull/3012](https://togithub.com/software-mansion/react-native-gesture-handler/pull/3012) #### New Contributors - [@​coado](https://togithub.com/coado) made their first contribution in [https://github.com/software-mansion/react-native-gesture-handler/pull/2983](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2983) - [@​amandeepmittal](https://togithub.com/amandeepmittal) made their first contribution in [https://github.com/software-mansion/react-native-gesture-handler/pull/2991](https://togithub.com/software-mansion/react-native-gesture-handler/pull/2991) **Full Changelog**: software-mansion/react-native-gesture-handler@2.17.0...2.18.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone America/Los_Angeles. 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/valora-inc/wallet). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJucG0iLCJyZW5vdmF0ZSJdfQ==--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: valora-bot <[email protected]>
This was referenced Sep 14, 2024
This was referenced Sep 20, 2024
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.
Description
Test plan