Using `@bugsnag/react-native` in monorepo
See original GitHub issueThis is not so much of a feature request but more to consult with maintainers how to fix a problem I faced trying to use it in monorepo environment. I don’t mind opening PR (as long as we reach a conclusion soon and I’m still in the loop 😃 )
Description
I am working on react-native app located inside learna managed monorepo. When I tried to upgrade to version 7 or bugsnag-js I started seeing lots of errors like https://github.com/bugsnag/bugsnag-js/issues/1255 :
> Could not find com.bugsnag:bugsnag-android:5.5.1-react-native.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/bugsnag/bugsnag-android/5.5.1-react-native/bugsnag-android-5.5.1-react-native.pom
- https://dl.google.com/dl/android/maven2/com/bugsnag/bugsnag-android/5.5.1-react-native/bugsnag-android-5.5.1-react-native.jar
- https://maven.google.com/com/bugsnag/bugsnag-android/5.5.1-react-native/bugsnag-android-5.5.1-react-native.pom
- https://maven.google.com/com/bugsnag/bugsnag-android/5.5.1-react-native/bugsnag-android-5.5.1-react-native.jar
- .....
eventually after reading these lines https://github.com/bugsnag/bugsnag-js/blob/8e142100e20880500c1d374871b6b7871aec1db6/packages/react-native/android/build.gradle#L51-L67 I figured a plugin makes certain assumptions about paths in a project which were not true in case of a package under packages/....
in a typical lerna monorepo.
I managed to fix these errors by adding
dependencies {
maven {
url "$rootDir/../../../node_modules/@bugsnag/react-native/android"
}
}
to my packages/app/android/build.gradle
Describe the solution you’d like
I would like this project to be easier to use in monorepo environment.
Describe alternatives you’ve considered
I consider 2 options which are good enough for me:
- https://github.com/bugsnag/bugsnag-js/blob/next/packages/react-native/android/build.gradle could be smarter about layout of directories (which I understand would be an assumption on it’s own)
- or simply add few lines into readme explaining how to fix these errors
Additional context
thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8 (4 by maintainers)
Top GitHub Comments
Hi @MohammadAzimi,
The
bugsnag { }
configuration should be in its own section outside of theandroid
block.With regards the error you see if you do that, have you added the line
apply plugin: "com.bugsnag.android.gradle"
after
apply from: "../../../node_modules/react-native/react.gradle"
within that file?https://docs.bugsnag.com/platforms/react-native/react-native/manual-setup/#android
As of https://github.com/bugsnag/bugsnag-android-gradle-plugin/releases/tag/v5.7.4 you can now specify where your
node_modules
directory is using thenodeModulesDir
Gradle configuration option which will allow you to use@bugsnag/react-native
in a monorepo.Update your Bugsnag Android Gradle Plugin dependency to
v5.7.4
. Then, in your app’sbuild.gradle
file, add to yourbugsnag
config:https://docs.bugsnag.com/build-integrations/gradle/#custom-node_modules-directory