haul CLI passthrough support for "react-native config"
jounii opened this issue · 4 comments
Describe the feature
Right now Haul CLI does not support all commands of react-native CLI. Especially the "config" command which outputs some configuration json data.
Feature would that haul.js would support config argument by just running react-native config
for compatibility.
Motivation
We are using Azure DevOps AppCenter to build our applications. AppCenter does not support Haul out of the box and it does not provide easy way to pass CLI_PATH. So we're using command ln -Ffsv ../\@haul-bundler/cli/bin/haul.js ./node_modules/react-native/cli.js
in the AppCenter hook script pre-build.sh
to switch the CLI to haul for bundling. The bundling seemed to work locally, as parameters are same.
However the way AppCenter set ups the project for building, is that the hook is run before it runs iOS build step for pod install --repo-update
. While this is not a problem, the problem comes from the Podfile itself which is running Ruby method use_native_modules!
. That in turn is using the react-native config
command to read json configuration to use for further actions. This fails the build as Haul doesn't support it.
So right now we are facing two options:
-
manage two babel.config.js files. One for metro (AppCenter) and one for developers on their local setups. AppCenter would have then hook setup to copy correct file before build. Downside is then that the developers would be using different build bundling than AppCenter and some incompatibility problems may be only noticed by AppCenter builds.
-
custom wrapper CLI command to do the feature request and run either haul.js or react-native cli.js based on arguments.
There are few other hacky solutions too, but those two seem most cleanest.
Related Issues
The Android build is still untested, if it has any similar issues on dependencies of react-native CLI commands.
I think this is a feature request for https://github.com/react-native-community/cli to add an option to specify bundler, so that the react-native
command would spawn Haul instead of Metro. Haul itself is just a bundling tool, not an alternative to react-native
CLI. Adding config
command to Haul doesn't make a lot of sense IMO.
cc: @thymikee
Sounds one option too, maybe a bit similar as the option 2 "higher order cli script" to pass bundle command to haul. Should be then possible to change through package.json and/or environment variable as in our case those would be only ways to affect the configuration.
I tried to do this through react-native.config.js
by overriding bundle
command. But it seems it's not possible to override existing commands. Have to see if I can change the bundle command at AppCenter.
https://github.com/react-native-community/cli/blob/master/docs/plugins.md
Anyway, if going this way, then this is not haul feature anymore.
I was able to override the CLI_PATH setting at AppCenter. It needs manual configuration in the build setup UI and seems it's not possible to configure it within the project inside repository through hooks. Solution for now is setting environment variables to:
CLI_PATH
to ./node_modules/@haul-bundler/cli/bin/haul.js
Would be nice to have this as project setting and not as build setting, but have to go with this now.