-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
Description
When building the app for iOS, if you set the env var SOURCEMAP_FILE when bundling it generates an error when composing sourcemaps.
As I understand the culprit appears to be this parts of the react-native-xcode.sh script:
If SOURCEMAP_FILE is not empty, then EMIT_SOURCEMAP.
EMIT_SOURCEMAP=
if [[ ! -z “$SOURCEMAP_FILE” ]]; then
EMIT_SOURCEMAP=true
fiHere it seems that if EMIT_SOURCEMAP is true, it generates the sourcemap in the bundle script
PACKAGER_SOURCEMAP_FILE=
if [[ $EMIT_SOURCEMAP == true ]]; then
if [[ $USE_HERMES == true ]]; then
PACKAGER_SOURCEMAP_FILE=“$CONFIGURATION_BUILD_DIR/$(basename $SOURCEMAP_FILE)”
else
PACKAGER_SOURCEMAP_FILE=“$SOURCEMAP_FILE”
fi
EXTRA_ARGS=“$EXTRA_ARGS --sourcemap-output $PACKAGER_SOURCEMAP_FILE”
fi
if [[ $USE_HERMES != true ]]; then
cp “$BUNDLE_FILE” “$DEST/”
BUNDLE_FILE=“$DEST/main.jsbundle”
else
EXTRA_COMPILER_ARGS=
if [[ $DEV == true ]]; then
EXTRA_COMPILER_ARGS=-Og
else
EXTRA_COMPILER_ARGS=-O
fiHere it where confuses me, I don't know (and couldn't find them) which flags and how they work for the Hermes compiler. Here the flag "-output-source-map" is setted but I don't actually know if it does something.
if [[ $EMIT_SOURCEMAP == true ]]; then
EXTRA_COMPILER_ARGS=“$EXTRA_COMPILER_ARGS -output-source-map”
fi
“$HERMES_CLI_PATH” -emit-binary $EXTRA_COMPILER_ARGS -out “$DEST/main.jsbundle” “$BUNDLE_FILE”And here is kind of weird too. It seems that a "mainjs.bundle.map" should exist next to "main.jsbundle" but it doesn't, hence causing the error.
if [[ $EMIT_SOURCEMAP == true ]]; then
HBC_SOURCEMAP_FILE=“$BUNDLE_FILE.map”
“$NODE_BINARY” “$COMPOSE_SOURCEMAP_PATH” “$PACKAGER_SOURCEMAP_FILE” “$HBC_SOURCEMAP_FILE” -o “$SOURCEMAP_FILE”
fi
BUNDLE_FILE=“$DEST/main.jsbundle”
fiThis is the build phase:
export NODE_BINARY=node
export SOURCEMAP_FILE=“${PROJECT_DIR}/../sourcemap.ios.js”
export PROJECT_ROOT=“${PROJECT_DIR}/../”
../../../node_modules/react-native/scripts/react-native-xcode.sh index.js
This is the XCode report:
bundle-xcode-report.txt
The error is:
+ [[ true == true ]]
+ HBC_SOURCEMAP_FILE=/Users/path/to/DerivedData/intermediates/BuildProductsPath/Release.development-iphoneos/main.jsbundle.map
+ node /Users/user/Workspace/UtilityGO-Office-Mobile/node_modules/react-native/scripts/compose-source-maps.js /Users/path/to/DerivedData/intermediates/BuildProductsPath/Release.development-iphoneos/sourcemap.ios.js /Users/path/to/DerivedData/intermediates/BuildProductsPath/Release.development-iphoneos/main.jsbundle.map -o /Users/path/to/ios/workspace/../sourcemap.ios.js
internal/fs/utils.js:314
throw err;
^
Error: ENOENT: no such file or directory, open '/Users/path/to/DerivedData/intermediates/BuildProductsPath/Release.development-iphoneos/main.jsbundle.map'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at Object.<anonymous> (/Users/user/Workspace/UtilityGO-Office-Mobile/node_modules/react-native/scripts/compose-source-maps.js:35:8)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/path/to/DerivedData/intermediates/BuildProductsPath/Release.development-iphoneos/main.jsbundle.map'
}
I don't know if I'm misunderstanding how SOURCEMAP_FILE works, if doing something wrong or is actually a bug.
It would be really great if I can get some help with this!
Thank you!
Version
0.65.1
Output of react-native info
System:
OS: macOS 11.6
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 1.15 GB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.3 - /var/folders/16/pt1bzhnj0t723m8dhdfjv8c80000gn/T/yarn--1635445381302-0.42400434651762153/node
Yarn: 1.22.10 - /var/folders/16/pt1bzhnj0t723m8dhdfjv8c80000gn/T/yarn--1635445381302-0.42400434651762153/yarn
npm: 7.24.0 - ~/Workspace/UtilityGO-Office-Mobile/node_modules/.bin/npm
Watchman: 2021.06.07.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK: Not Found
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7583922
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: javac 17 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
Add SOURCEMAP_FILE env var when bundling, like this:
export NODE_BINARY=node
export SOURCEMAP_FILE=“${PROJECT_DIR}/../sourcemap.ios.js”
export PROJECT_ROOT=“${PROJECT_DIR}/../”
../../../node_modules/react-native/scripts/react-native-xcode.sh index.js
Snack, code example, screenshot, or link to a repository
No response