From c4289869db8a757a0b93f7587b34c3b6b35e90d9 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Tue, 23 May 2023 10:04:26 +0200 Subject: [PATCH] fix: limit diagnostics width output by `hermesc` --- .../facebook/react/tasks/BundleHermesCTask.kt | 1 + .../react/tasks/BundleHermesCTaskTest.kt | 22 ++++++++++--------- .../scripts/react-native-xcode.sh | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt index 55eab602f4d0f3..78e5a9b2606ce5 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt @@ -174,6 +174,7 @@ abstract class BundleHermesCTask : DefaultTask() { return windowsAwareCommandLine( hermesCommand, "-emit-binary", + "-max-diagnostic-width=80", "-out", bytecodeFile.cliPath(rootFile), bundleFile.cliPath(rootFile), diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BundleHermesCTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BundleHermesCTaskTest.kt index 3e07a78b36e1b4..f7feb2b11735f5 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BundleHermesCTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/BundleHermesCTaskTest.kt @@ -341,11 +341,12 @@ class BundleHermesCTaskTest { assertEquals(customHermesc, hermesCommand[0]) assertEquals("-emit-binary", hermesCommand[1]) - assertEquals("-out", hermesCommand[2]) - assertEquals(bytecodeFile.absolutePath, hermesCommand[3]) - assertEquals(bundleFile.absolutePath, hermesCommand[4]) - assertEquals("my-custom-hermes-flag", hermesCommand[5]) - assertEquals(6, hermesCommand.size) + assertEquals("-max-diagnostic-width=80", hermesCommand[2]) + assertEquals("-out", hermesCommand[3]) + assertEquals(bytecodeFile.absolutePath, hermesCommand[4]) + assertEquals(bundleFile.absolutePath, hermesCommand[5]) + assertEquals("my-custom-hermes-flag", hermesCommand[6]) + assertEquals(7, hermesCommand.size) } @Test @@ -366,11 +367,12 @@ class BundleHermesCTaskTest { assertEquals("/c", hermesCommand[1]) assertEquals(customHermesc, hermesCommand[2]) assertEquals("-emit-binary", hermesCommand[3]) - assertEquals("-out", hermesCommand[4]) - assertEquals(bytecodeFile.relativeTo(tempFolder.root).path, hermesCommand[5]) - assertEquals(bundleFile.relativeTo(tempFolder.root).path, hermesCommand[6]) - assertEquals("my-custom-hermes-flag", hermesCommand[7]) - assertEquals(8, hermesCommand.size) + assertEquals("-max-diagnostic-width=80", hermesCommand[4]) + assertEquals("-out", hermesCommand[5]) + assertEquals(bytecodeFile.relativeTo(tempFolder.root).path, hermesCommand[6]) + assertEquals(bundleFile.relativeTo(tempFolder.root).path, hermesCommand[7]) + assertEquals("my-custom-hermes-flag", hermesCommand[8]) + assertEquals(9, hermesCommand.size) } @Test diff --git a/packages/react-native/scripts/react-native-xcode.sh b/packages/react-native/scripts/react-native-xcode.sh index 9f80ef20246e55..7e2f1190771cb5 100755 --- a/packages/react-native/scripts/react-native-xcode.sh +++ b/packages/react-native/scripts/react-native-xcode.sh @@ -176,7 +176,7 @@ else 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" + "$HERMES_CLI_PATH" -emit-binary -max-diagnostic-width=80 $EXTRA_COMPILER_ARGS -out "$DEST/main.jsbundle" "$BUNDLE_FILE" if [[ $EMIT_SOURCEMAP == true ]]; then HBC_SOURCEMAP_FILE="$DEST/main.jsbundle.map" "$NODE_BINARY" "$COMPOSE_SOURCEMAP_PATH" "$PACKAGER_SOURCEMAP_FILE" "$HBC_SOURCEMAP_FILE" -o "$SOURCEMAP_FILE"