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): drop @babel/plugin-transform-destructuring plugin #27885

Closed
wants to merge 2 commits into from

Conversation

EvanBacon
Copy link
Contributor

Why

  • Fast forward chore: remove @babel/plugin-transform-destructuring plugin facebook/react-native#43662
  • This transform pulls in a helper module to every file with destructuring (i.e. any file with `).
  • In an Expo Router iOS app (hermes, no minify) there are are 77 fewer resolutions (from 1721 to 1644) ~4.4% decrease, and 10 less modules (from 776 to 766). In a fully cached build, it's about 10-15ms faster (with fast resolver) (~330ms down to ~315ms).
  • Ultimately, this PR helps unblock our ability to add a transform for optimizing server components that are shared across server/client. A shared component should be able to add useState and have it automatically removed when running in the server to prevent errors. This transform generally requires that we keep the useState syntax intact.

How

  • The canary flag is only used to toggle this plugin, enabling it allows us to disable destructuring transforms.

Test Plan

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Mar 27, 2024
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 Mar 27, 2024
@EvanBacon
Copy link
Contributor Author

Thank goodness for our E2E tests, they caught a missing language feature in Hermes that isn't documented:

error: Destructuring in catch parameters is currently unsupported

Which comes from:

try {

} catch ({ message }) {

}

I guess destructuring isn't supported in Hermes. Closing for now since Hermes development is frozen, cite: facebook/react-native#43662 (comment)

@EvanBacon EvanBacon closed this Mar 27, 2024
@EvanBacon EvanBacon deleted the @evanbacon/babel/drop-destructuring-plugin branch March 27, 2024 17:39
EvanBacon added a commit that referenced this pull request Mar 28, 2024
# Why

- Inspired by #27885
- Even though we have tests which catch a wide range of missing language
features, it would be nice to have the tests fail faster and in
isolation from a native build. Right now, they only run after a full
native build has completed, which could lead to instances where the
native build fails and we think it's fine to land anyways.


<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

# How

- Add Hermes compilation to the babel jest tests and a number of
language.

<!--
How did you build this feature or fix this bug and why?
-->

# Test Plan

- There's a chance this PR doesn't work in CI.


<!--
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants