React Native JS bundle crashes on iOS Release, Bab

2019-08-21 12:48发布

问题:

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?