@apoyando Thanks for your help I’ve been struggling with this.
You may be right. It looks like my App.js imports both my NativeApp and my WebApp and then conditionally exports the right one based on what Platform.OS says. Is there a way to have two different entry points?
I also have this strange line in it. Not sure why… might be related? export * from './src/src/App';
(which is my native app)
Full code:
import NativeApp from './src/src/App';
import WebApp from './src/src/web/App';
import { Platform } from 'react-native';
let app = NativeApp as any;
if (Platform.OS === 'web') {
app = WebApp;
}
export default app;
export * from './src/src/App';
@vjsingh If you’re always exporting * from your native app entry, you’re always going to get your Sentry initialization from there.
If your web app actually needs exports from what is now your native app entry, then you might want to rethink the way you’ve structured your project. If not, then the “export *” is at best unnecessary.
Again, the web vs native logic you’re using could be replaced by using platform-specific files. You could simply import app from './App' in the file you quote above, and then create App.native.js and App.web.js files to import the right entries from the right directories.
@apoyando Thanks so much! This is actually a huge help for us. I’ve wasted countless hours dealing with issues where my web project wouldn’t compile because of an import that was only in my native code.
I won’t have time to look at this until next week but it looks like it should work.
@charliecruzan I can’t find any mention of the app.native.js and app.web.js files in the Expo documentation. Did I miss it, or if not would it be worth adding?