react-navigation / redux-helpers

Redux middleware and utils for React Navigation
Other
296 stars 43 forks source link

Bundler error in `middleware.js` #42

Closed tostr7191 closed 6 years ago

tostr7191 commented 6 years ago

Hi

Currently we are updating various packages in our app but it seems we struck a problem with you package:

error: bundling failed: SyntaxError: /<snip>/node_modules/react-navigation-redux-helpers/src/middleware.js: Unexpected token (149:0)

We are running:

    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
<snip>
    "react-navigation": "2.3.1",
    "react-navigation-redux-helpers": "2.0.2",

Are we missing something or is this a bug? I have tried numerous version combinations, the error moves around in the file but stays the same.

Thanks & Best tostr

Ashoat commented 6 years ago

I am not sure why this is occurring. Perhaps it has to do with a quirk in your build environment. Do you have a custom .babelrc set up, or are you using Haul or something?

tostr7191 commented 6 years ago

We have changed the following in middleware.js:

# removed at the bottom:
export {
  createReactNavigationReduxMiddleware,
  createDidUpdateCallback,
  initializeListeners,
  createNavigationPropConstructor,
};

# added export directly in front of the functions

Now it does no longer crash there. Our .babelrc is nothing special I think:

{
  "presets": ["react-native"]
}

Babel packages:

  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-jest": "23.0.1",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-native": "^4.0.0",
    "babel-preset-stage-2": "^6.24.1",
<snip>

I see that it might be a problem on our side, but I can't really figure out where to look, do you see anything that's looking wrong from your perspective?

(We are using node v8.11.3 btw)

Ashoat commented 6 years ago

That's really weird. I can't imagine what's going wrong with the export syntax. You're sure there's nothing non-standard in your build system? You're using a stock react-native init or create-react-native-app config?

tostr7191 commented 6 years ago

Hi

We have solved the problem, how exactly I can't really tell. But deleting the yarn.lock file and reinstalling all packages made the problem disappear. Probably something messed up among some larger upgrades we have done that just happened to trigger this specific error!

Thanks for your help and sorry for the inconvenience :) tostr