I faced the following issue https://github.com/callstack/react-native-testing-library/issues/955. Production build is failed and error points to the library from devDependencies.
Answer from Satyajit Sahoo on Reddit.
The app contains what you import. Doesn't matter if it's in dependencies, devDependencies or you just created a file. Those fields are to tell npm/Yarn about what to install. Bundling looks only at your imports.
If your bundle contains code from testing library`, then you're importing it into some file that's imported by your entry point.