react-native-community / cli

React Native command line tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting `buildTypes` for a dependency still adds it to main list of packages, is this expected?

marqroldan opened this issue · comments

Ask your Question

I might have misunderstood the purpose of buildTypes but I thought explicitly defining it would make the dependency/package only be included when the selected mode is in the list...

I'm trying to exclude a package from the default debug buildType and only include it in the debugHuawei build type

my react-native.config.js

module.exports = {
  assets: [],
  iosAssets: ['./src/assets/fonts/'],
  project: {
    ios: {},
    android: {}, // grouped into "project"
  },
  dependencies: {
    'react-native-flipper': {
      platforms: {
        ios: null,
      },
    },
    '@hmscore/react-native-hms-map': {
      platforms: {
        ios: null,
        android: {
          buildTypes: ['debugHuawei'],
        },
      },
    },
  },
};

However it's still included in the list of packages (PackageList.java) which breaks the build

// @hmscore/react-native-hms-map
import com.huawei.hms.rn.map.HMSMapPackage;

...

  public ArrayList<ReactPackage> getPackages() {
    return new ArrayList<>(Arrays.<ReactPackage>asList(
      new MainReactPackage(mConfig),
      new FlipperPackage(),
      new HMSMapPackage(),

setting android: null would exclude it from the list, but I can't exactly access the mode in the js file when I do npx react-native run-android --mode=debugHuawei

I'd like to please ask for some guidance 😅 thank you

My CLI version is 11.3.10 but the logic hasn't really changed that much


EDIT 2: I realize I could access process.argv :D i could set it to null now lol
EDIT 3: Ok so since it's also triggered by the gradle logic, the original args doesn't get passed and so this approach fails...
EDIT 4: I ended up creating a lock file when I know the command is with build-android or run-android so when the gradle executes the file it would check for the existence of the lock file and get the value