fix(cli): explicitly reference env vars in native template for Metro inlining#988
fix(cli): explicitly reference env vars in native template for Metro inlining#988shkumbinhasani wants to merge 1 commit intoAmanVarshney01:mainfrom
Conversation
…inlining Metro's transform for EXPO_PUBLIC_* env vars only works on individual property accesses (process.env.EXPO_PUBLIC_X), not on passing process.env as a whole object. In production Hermes bytecode bundles, process.env resolves to an empty object, causing Zod validation to throw and crash the app on startup. Fixes AmanVarshney01#987
|
@shkumbinhasani is attempting to deploy a commit to the Better T Stack Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe changes modify environment variable configuration in generated template files by replacing Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
runtimeEnv: process.envwith explicit per-variable references (process.env.EXPO_PUBLIC_*) in the native env template so Metro can inline them during production Hermes bytecode bundlingprocess.envresolves to an empty object in production iOS builds, causing Zod validation to throw and crash the app on startupDetails
Metro's transform for
EXPO_PUBLIC_*environment variables only works on individual property accesses likeprocess.env.EXPO_PUBLIC_SERVER_URL— it performs AST-level replacement. Passingprocess.envas a whole object toruntimeEnvresults in an empty object in production Hermes bytecode bundles. This works in development because Metro dev server handlesprocess.envdifferently.Test plan
native.tsoutput has explicit env var referencesFixes #987
Summary by CodeRabbit