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): transform based on engine #24672

Merged
merged 7 commits into from Sep 29, 2023

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Sep 29, 2023

Why

  • Reduce the amount of Babel transformations based on the jsEngine for a particular platform.
  • Hermes supports more modern language features than the default React Native target, so we don't have to transpile as much. This is an unstable feature that seems reasonable enough to turn on by default.
  • Users can overwrite the default by using the same unstable_transformProfile as before.
  • Web will also use this newer transform as the majority of modern browsers support more features than Hermes.

The following will now be disabled when using Hermes:

@babel/plugin-transform-computed-properties
@babel/plugin-transform-parameters
@babel/plugin-transform-shorthand-properties
@babel/plugin-proposal-optional-catch-binding
@babel/plugin-transform-function-name
@babel/plugin-transform-literals
@babel/plugin-proposal-numeric-separator
@babel/plugin-transform-sticky-regex
@babel/plugin-transform-spread
@babel/plugin-proposal-object-rest-spread
@babel/plugin-proposal-optional-chaining
@babel/plugin-proposal-nullish-coalescing-operator
@babel/plugin-transform-runtime -> regenerator

And @babel/plugin-transform-named-capturing-groups-regex will be enabled.

Expressed as a diff:

Screenshot 2023-09-28 at 6 03 17 PM

How

  • Add an engine flag to the URL to trigger a cache invalidation per-platform if the app.json settings change.
  • Pass the flag to babel where we can toggle on Hermes mode.

Test Plan

  • Tested in sandbox, also wrote unit tests for the syntax.

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 Sep 29, 2023
@EvanBacon EvanBacon merged commit 2dac7b9 into main Sep 29, 2023
10 of 12 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/cli/transform-for-hermes branch September 29, 2023 19:55
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