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

fix(cli): perform environment variable inlining in transformer to support source maps #25239

Merged
merged 6 commits into from Nov 7, 2023

Conversation

EvanBacon
Copy link
Contributor

Why

The current environment variable inlining is an extension of the development-mode support which runs in the serializer and doesn't support caching. While the new approach is to inline environment variables during transformation of production modules that are targeting client code (which is rarely ever cached).

The purpose of this change is to ensure sourcemaps cannot be broken by performing the modification before sourcemaps are generated. This change should also enable devs to use Expo env vars for tree shaking as they'll be inlined before minification is performed.

How

  • Pass a new inlineEnvVars setting which reflects the EXPO_NO_CLIENT_ENV_VARS environment variable and invalidates the transform cache.
  • Add a new babel plugin which inlines EXPO_PUBLIC_ environment variables that don't exist in node_modules.
  • Modify the development serializer to do nothing in production.
  • Unify the custom transform settings logic a little more than before.

Test Plan

  • Added new babel tests that are based on the serializer tests. These are more robust because it's easier to test transformation e2e than serialization.
  • Existing e2e metro tests should cover the production cases.

Checklist

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 6, 2023
EvanBacon added a commit that referenced this pull request Nov 7, 2023
# Why

Unclear why tests ever worked because they use the same ports to perform
bundling. We can revisit in the future by removing the need for a port,
but for now I'm making all e2e bundler tests run in band. Unblocks test
issues here #25239

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@EvanBacon EvanBacon merged commit f2bee0b into main Nov 7, 2023
12 checks passed
@EvanBacon EvanBacon deleted the @evanbacon/cli/fix-env-var-source-maps branch November 7, 2023 06:36
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