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(babel): fix unused platform code removal #25171
Conversation
packages/babel-preset-expo/src/__tests__/platform-shaking.test.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
# Why Tests were technically failing, this fixes them. Related #25171
@@ -98,6 +98,21 @@ function babelPresetExpo(api: ConfigAPI, options: BabelPresetExpoOptions = {}): | |||
extraPlugins.push(require('@babel/plugin-transform-parameters')); | |||
} | |||
|
|||
if (!isDev && hasModule('metro-transform-plugins')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why should this not run in development, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do any minification in development to keep things fast, might change in the future but right now it doesn't provide much benefit.
Why
Metro applies this plugin too but it does it after the imports have been transformed which breaks the plugin. Here, we'll apply it before the commonjs transform, in production, to ensure
Platform.OS
is replaced with a string literal and__DEV__
is converted to a boolean.Applying early also means that web can be transformed before the
react-native-web
transform mutates the import.Test Plan
Checklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).