diff --git a/CHANGELOG.md b/CHANGELOG.md index 55d937a905..56a38d20a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- Dynamically resolve `collectModulesScript` path to support monorepos ([#3092])(https://github.com/getsentry/sentry-react-native/pull/3092) + ### Dependencies - Bump JavaScript SDK from v7.52.0 to v7.52.1 ([#3071](https://github.com/getsentry/sentry-react-native/pull/3071)) diff --git a/sentry.gradle b/sentry.gradle index 28230102cb..b4671fa477 100644 --- a/sentry.gradle +++ b/sentry.gradle @@ -166,9 +166,15 @@ gradle.projectsEvaluated { workingDir reactRoot + def resolvedSentryPath = null + try { + resolvedSentryPath = new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile(); + } catch (Throwable ignored) {} // if the resolve fails we fallback to the default path + def sentryPackage = resolvedSentryPath != null && resolvedSentryPath.exists() ? resolvedSentryPath.getAbsolutePath() : "$reactRoot/node_modules/@sentry/react-native" + def collectModulesScript = config.collectModulesScript ? file(config.collectModulesScript).getAbsolutePath() - : "$reactRoot/node_modules/@sentry/react-native/dist/js/tools/collectModules.js" + : "$sentryPackage/dist/js/tools/collectModules.js" def modulesPaths = config.modulesPaths ? config.modulesPaths.join(',') : "$reactRoot/node_modules"