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

feat(cli, router, babel): add router root to metro cache #25658

Merged
merged 8 commits into from Nov 30, 2023

Conversation

EvanBacon
Copy link
Contributor

Why

  • Add support for invalidating the cache when the app directory changes. We use this feature in our E2E tests so it would be good to ensure it works properly.
  • This change also enables us to move the Expo config read operation out of the babel preset which should generally be safer and faster.
  • By adding this invalidation we also ensure that the cache is cleared when expo-router is installed, this should help reduce issues related to manual expo-router installation in existing projects.
  • This change also deletes expo-router/babel in favor of babel-preset-expo which is properly tested.
  • I've also added the option to change the root directory to the docs and noted that it's a dangerous operation that may lead to issue closing.

Test Plan

  • Ensure project continue working.
  • Ensure the cache clears when the root directory changes.

Checklist

EvanBacon and others added 5 commits November 29, 2023 23:55
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
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 30, 2023
Copy link
Member

@amandeepmittal amandeepmittal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small suggestions but LGTM!

docs/pages/router/reference/src-directory.mdx Outdated Show resolved Hide resolved
docs/pages/router/reference/src-directory.mdx Outdated Show resolved Hide resolved
docs/pages/router/reference/src-directory.mdx Outdated Show resolved Hide resolved
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
@EvanBacon EvanBacon merged commit 2273cbe into main Nov 30, 2023
10 of 12 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/cli/add-router-root-to-metro-cache branch November 30, 2023 17:22
@pvinis
Copy link
Contributor

pvinis commented Dec 6, 2023

Seems like on 2.0.14 we still get

ValidationError: Invalid options object. expo-router config plugin has been initialized using an options object that does not match the API schema.
 - options has an unknown property 'root'. These properties are valid:
   object { origin?, headOrigin?, unstable_src?, asyncRoutes? }

when trying to use "root" like the docs here https://docs.expo.dev/router/reference/src-directory/#custom-directory.

onizam95 pushed a commit to onizam95/expo-av-drm that referenced this pull request Jan 15, 2024
# Why

- Add support for invalidating the cache when the app directory changes.
We use this feature in our E2E tests so it would be good to ensure it
works properly.
- This change also enables us to move the Expo config read operation out
of the babel preset which should generally be safer and faster.
- By adding this invalidation we also ensure that the cache is cleared
when expo-router is installed, this should help reduce issues related to
manual expo-router installation in existing projects.
- This change also deletes `expo-router/babel` in favor of
`babel-preset-expo` which is properly tested.
- I've also added the option to change the root directory to the docs
and noted that it's a dangerous operation that may lead to issue
closing.

# Test Plan

- Ensure project continue working.
- Ensure the cache clears when the root directory changes.

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Co-authored-by: Aman Mittal <amandeepmittal@live.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

4 participants