expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
829 stars 84 forks source link

Source code is not preserved in EAS development builds when 'show source' is used with Hermes #2034

Open andrey-abstracted opened 1 year ago

andrey-abstracted commented 1 year ago

Build/Submit details page URL

https://expo.dev/accounts/duxa/projects/test-app/builds/e026acc3-9e93-492b-921b-4eaca532e769

Summary

In EAS development builds .toString() returns byte code for functions where 'show source' directive is used which should be preserving source code with Hermes. Works correctly in EAS production builds.

This is the description of the directive https://github.com/facebook/hermes/issues/114#issuecomment-887106990

It is possible that the Metro bundler strips the bundle of the directive

Managed or bare?

eas build

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.5 Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 9.8.1 - /usr/local/bin/npm Watchman: 2023.06.26.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7583922 Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild npmPackages: expo: ~49.0.8 => 49.0.8 react: 18.2.0 => 18.2.0 react-native: 0.72.4 => 0.72.4 npmGlobalPackages: eas-cli: 5.0.2 Expo Workflow: managed

Error output

showMySource.toString() prints out the following: function showMySource() { [bytecode] }

Reproducible demo or steps to reproduce from a blank project

import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View } from 'react-native';

export default function App() {

function showMySource(){ 'show source'; var a = 3; var b = 4; var c = a+b; }

return ( <View style={styles.container}> <Text>{showMySource.toString()}</Text> <StatusBar style="auto" /> </View> ); }

const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, });

AlanSl commented 8 months ago

Edit: my specific similar issue below (it not working on first load only) seems to be a known issue on Hermes: 'show source' does not work on first run when debugging, see also Hermes "show source" not working in debug mode. which is similar but not resolved in hot reloads.


I see the same issue (Expo 50.0.7 and 49.0.15), but curiously, only in the initial load, not on "hot reload" after making and saving an incidental change. There's another similar report over on the original issue on Hermes, that is also specific to Expo and mentions it being only on initial dev build load, and not hot reload.

Given something like this:

function someFunction () {
  'show source'
  return 'hello'
}
console.log(someFunction.toString())

If "Fast Refresh" is disabled in the Expo Dev menu, it always shows the [byteCode] fail case; if I re-enable it, it does a hot reload that causes the full function code to show, and reverts to the above behaviour.

andflett commented 1 month ago

@AlanSl realise it's been months, but did you ever find a way around this? Experiencing exactly the same thing.