Skip to content

Commit 57cc01c

Browse files
committed
Copy bundle and source map files to a specific build folder
1 parent 82fe4b6 commit 57cc01c

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

WordPress/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,3 +719,20 @@ if (project.hasProperty("debugStoreFile")) {
719719
}
720720
}
721721
}
722+
723+
// Copy React Native JavaScript bundle and source map so they can be upload it to the Crash logging
724+
// service during the build process.
725+
android {
726+
applicationVariants.all { variant ->
727+
variant.mergeAssetsProvider.configure {
728+
doLast {
729+
// Copy bundle and source map files
730+
copy {
731+
from(outputDir)
732+
into("${buildDir}/react-native-bundle-source-map")
733+
include("*.bundle", "*.bundle.map")
734+
}
735+
}
736+
}
737+
}
738+
}

fastlane/lanes/build.rb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -388,25 +388,20 @@ def upload_gutenberg_sourcemaps(app:, flavor:, build_type:, release_version:)
388388
# The format is: <app><flavor><build_type>
389389
# E.g.: jetpackJalapenoDebug
390390
build_asset_folder_name = "#{app.downcase}#{flavor}#{build_type}"
391-
bundle_source_map_path = File.join(PROJECT_ROOT_FOLDER, 'WordPress', 'build', 'intermediates', 'assets', build_asset_folder_name)
392-
393-
Dir.mktmpdir do |sourcemaps_folder|
394-
# It's important that the bundle and source map files have specific names, otherwise, Sentry won't symbolicate the stack traces.
395-
FileUtils.cp(File.join(bundle_source_map_path, 'index.android.bundle'), File.join(sourcemaps_folder, 'index.android.bundle'))
396-
FileUtils.cp(File.join(bundle_source_map_path, 'index.android.bundle.map'), File.join(sourcemaps_folder, 'index.android.bundle.map'))
397-
398-
sentry_upload_sourcemap(
399-
auth_token: sentry_token,
400-
org_slug: org_slug,
401-
project_slug: project_slug,
402-
version: release_version,
403-
dist: current_build_code,
404-
# When the React native bundle is generated, the source map file references include the local machine path;
405-
# With the `rewrite` and `strip_common_prefix` options, Sentry automatically strips this part.
406-
rewrite: true,
407-
strip_common_prefix: true,
408-
sourcemap: sourcemaps_folder
409-
)
410-
end
391+
# Bundle and source map files are copied to a specific folder as part of the build process.
392+
bundle_source_map_path = File.join(PROJECT_ROOT_FOLDER, 'WordPress', 'build', 'react-native-bundle-source-map')
393+
394+
sentry_upload_sourcemap(
395+
auth_token: sentry_token,
396+
org_slug: org_slug,
397+
project_slug: project_slug,
398+
version: release_version,
399+
dist: current_build_code,
400+
# When the React native bundle is generated, the source map file references include the local machine path;
401+
# With the `rewrite` and `strip_common_prefix` options, Sentry automatically strips this part.
402+
rewrite: true,
403+
strip_common_prefix: true,
404+
sourcemap: bundle_source_map_path
405+
)
411406
end
412407
end

0 commit comments

Comments
 (0)