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

chore(babel-preset-expo, jest-expo, cli)!: Move react-native-vector-icons alias to resolvers #25512

Merged
merged 6 commits into from
Nov 22, 2023

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Nov 22, 2023

Why

Aliases in the resolver are more resilient (no chance of differences in importing logic between babel plugin and bundler), faster (no additional AST traversal needed), and easier to cache (cache based on input context rather than AST).

How

This PR removes the need to perform an additional import traversal to replace react-native-vector-icons with @expo/vector-icons by moving the alias to a conditional resolver in both Metro and Jest as opposed to having it in babel-preset-expo with babel-plugin-module-resolver.

To preserve backwards compatibility, I've also added support for nested imports, e.g. react-native-vector-icons/FontAwesome -> @expo/vector-icons/FontAwesome, even though we don't perform a strict check on the import existence.

Test Plan

  • Added new tests for the resolver.
  • Removed old tests for babel.
  • Existing code using Jest should continue to work.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Nov 22, 2023
EvanBacon and others added 2 commits November 21, 2023 18:36
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Nov 22, 2023
@EvanBacon EvanBacon merged commit 3354c46 into main Nov 22, 2023
10 of 11 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/cli/move-vector-icons-alias branch November 22, 2023 03:33
onizam95 pushed a commit to onizam95/expo-av-drm that referenced this pull request Jan 15, 2024
…cons alias to resolvers (expo#25512)

# Why

Aliases in the resolver are more resilient (no chance of differences in
importing logic between babel plugin and bundler), faster (no additional
AST traversal needed), and easier to cache (cache based on input context
rather than AST).


# How

This PR removes the need to perform an additional import traversal to
replace `react-native-vector-icons` with `@expo/vector-icons` by moving
the alias to a conditional resolver in both Metro and Jest as opposed to
having it in `babel-preset-expo` with `babel-plugin-module-resolver`.

To preserve backwards compatibility, I've also added support for nested
imports, e.g. `react-native-vector-icons/FontAwesome` ->
`@expo/vector-icons/FontAwesome`, even though we don't perform a strict
check on the import existence.

# Test Plan

- Added new tests for the resolver.
- Removed old tests for babel.
- Existing code using Jest should continue to work.

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants