0

My React Native build compiles in Debug and runs fine, but when I run my Release scheme the spread operators are throwing errors, causing the build to crash. Specifically, the first error thrown is from a spread operator in the NativeBase library.

For reference, my .babelrc is here:

{
    "presets": ["stage-3", "react-native"],
    "plugins": [
      "transform-es2015-destructuring", 
      "transform-object-rest-spread",
      "syntax-object-rest-spread",
      [
         "import", {
            "libraryName": "antd-mobile",
            "style": true
         }
      ]
    ]
}

The first error thrown in the bundled main.js is Unexpected token '...'. on the line with { ...props.children }:

props.type === 'checkbox' ? _react2.default.createElement(
    _reactNative.View, {
        style: babelHelpers.extends({}, styles, {
            height: 40,
            flexDirection: 'column'
        })
    }, { ...props.children }
)

Why is this error coming up in my Release build and not my Debug? And how might one fix it?

user1791914
  • 616
  • 9
  • 23
  • Do you have to stick to `stage 3`? is upgrading to `env` an option? – ReyHaynes May 09 '18 at 02:44
  • In case of RN, I would suggest to use pristine default babel config that RN creates for your. And if you need some tuning, make one small change at time and test very carefully (note: adding another preset is not a small change). –  May 09 '18 at 07:00
  • Thank you @ReyHaynes and vovkasm. I had to put this aside for a few days, but revisiting now. Good suggestions - I've tried them all. Signs are pointing to some kind of syntax in the JS causing a strange side effect when compiled. I'm testing each module individually to find exactly where. I will report back when I find the issue. – user1791914 May 11 '18 at 17:40

0 Answers0