How to make ejection to ExpoKit a build step?

#1

I want to keep my codebase un-ejected with Expo as the development workflow is a lot nicer. However, ejection is necessary for some things I need to add (payments and bug reporting with Instabug). I would like to make the ejection into a build step so that I can keep my code un-ejected.

Most of this can be simply done with some scripts that run pod install, react-native link for the necessary dependencies and make any modifications needed to MainApplication.java, etc.

My main question is how can I conditionally import dependencies in my code so that they are only imported if ejected? For example, right now I have the following code in my App.js to set up Instabug:

import Instabug from 'instabug-reactnative'

class App extends React.Component {
  componentDidMount() {
    Instabug.startWithToken(INSTABUG_TOKEN, [Instabug.invocationEvent.shake])
  }
}

However, Instabug requires my codebase to be ejected, so I can’t have this in my un-ejected codebase. I would like to do something more along the lines of:

class App extends React.Component {
  componentDidMount() {
    if (IS_EJECTED) {
      import('instabug-reactnative').then(Instabug => {
        Instabug.startWithToken(INSTABUG_TOKEN, [Instabug.invocationEvent.shake])
      })
    }
  }
}

However, I don’t really know how to figure out if I’m ejected or not. Basically, I am unsure how I can have that IS_EJECTED variable. Any advice with this or with ejecting as a build step in general would be much appreciated!

#2

Maybe this will help.

https://expo.canny.io/feature-requests/p/ability-to-work-in-expo-client-after-detaching

1 Like
closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.