question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`haul init` clobbers existing project.ext.react gradle config

See original GitHub issue

Current Behavior

haul init adds the following block to my project’s android/app/build.gradle above the react.gradle import, which overwrites my existing project.ext.react assignment.

project.ext.react = [
    cliPath: "node_modules/haul/bin/cli.js"
]

Expected Behavior

haul init should merge the new cliPath property into project.ext.react config if it exists, or fall back to the current behavior and create a new project.ext.react block.

Haul Configuration (webpack.haul.js)

module.exports = () => ({
  entry: `./index.js`,
});

Your Environment

software version
Haul 1.0.0-beta.13
react-native 0.53.0
node v9.3.0
npm or yarn v1.3.2

Workaround is just to manually merge the two project.ext.react blocks, but it’d be nice if haul init did this for you.

It looks like it just needs a bit more logic where it adds this block here

I’m happy to PR a fix in the coming week : )

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thymikeecommented, Mar 1, 2018

If that helps the case, but we can also search for existing project.ext.react and bailout with a proper warning to the user

0reactions
FLGMwtcommented, Mar 1, 2018

I think we can get away with not doing anything clever string-wise (especially since we’d have to deal with comments and multiple possible locations where project.ext.react is manipulated). Since we’re doing the replacing right about the react.gradle import and I think we can be reasonably sure this is the furthest down in the config that the user would assign their own ext.react values, how about just swapping out the snippet with a graceful initialization of ext.react and then a more surgical cliPath assignment? We’d end up with giving the user the following:

if (!project.hasProperty('react')) {
    project.ext.react = [:]
}
project.ext.react['cliPath'] = "node_modules/haul/bin/cli.js"

apply from: "../../node_modules/react-native/react.gradle"
Read more comments on GitHub >

github_iconTop Results From Across the Web

haul/Configuring_Your_Project.md at master - GitHub
Haul is a command line tool for developing React Native apps, ... run the following to automatically configure your gradle config to use...
Read more >
Getting Started · Haul
Start by adding Haul as a dependency to your React Native project (use react-native init MyProject to create one if you don't have...
Read more >
0 - Stack Overflow
to my android/app/build.gradle file and generated the following wepack.haul.js file. const path = require("path ...
Read more >
Bundling React Native during Android release builds
gradle file, we were able to hook into the bundling command on all our release builds. Our config: // Configures the bundleJS commands...
Read more >
Config variables for React Native apps - npm
Setup · android/settings.gradle include ':react-native-config' + project(':react-native-config').projectDir = new File(rootProject.projectDir, ' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found