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(metro): use custom babel-transformer #23607

Merged
merged 12 commits into from
Jul 27, 2023
Merged

Conversation

EvanBacon
Copy link
Contributor

@EvanBacon EvanBacon commented Jul 19, 2023

Why

Historically, we've avoided using a custom Metro babel transformer because some users leverage this value to transform certain files. However, we need to be able to pass custom options to the babel configuration like metroTarget and we also need to ensure babel-preset-expo is always used. These two aspects ensure Node.js environments can be accounted for in babel-preset-expo.

How

  • Fork the upstream babel-transformer.
    • Modify the fork to use babel-preset-expo by default when a babel.config.js isn't defined.
    • Expose the metroTarget field to the Babel caller. This is either client, node, or undefined. When defined, we'll use this to strip server code, and use more focused babel transforms (not yet implemented).
  • Expose the fork under @expo/metro-config/babel-transformer.
  • Add docs on how to extend the Expo metro babel transformer.
  • Delete the previous wrapper that was used when no babel.config.js file was defined.

Test Plan

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Jul 19, 2023
@EvanBacon EvanBacon marked this pull request as ready for review July 25, 2023 17:23
EvanBacon and others added 4 commits July 25, 2023 12:25
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
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.

Lgtm from docs perspective 👍

@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing changelog entries


Your changes should be noted in the changelog. Read Updating Changelogs guide and consider adding an appropriate entry to the following changelogs:


Generated by ExpoBot 🤖 against da0b09d

@EvanBacon EvanBacon merged commit 5acac6e into main Jul 27, 2023
13 of 14 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/metro/push-node-env branch July 27, 2023 18:30
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants