0
votes

I used react-native init and have reached a good point with my app, but now it's giving me serious issues with babel out of nowhere.

I got Unexpected use of reserved word 'import' went through steps: 1. clear watchman watches. 2. re-yarn all node modules 3. reset Metro Bundler Cache 4. Remove haste cache.

I've also deleted my .babelrc file because RN supposedly bundles the correct babel settings.

On Android emulator i get unable to resolve module babel-polyfill.

On Xcode / Simulator i also get unable to resolve module babel-polyfill from project's index.js

At my wit's end here. Tried uninstalling various incarnations of babel.

Versions: RN v0.55.4

i still have pkg json dev dependency of:

"metro-react-native-babel-preset": "^0.50.0"

but i think thats default wrapped in RN so kind of moot.

What am i missing and is there a sane way of setting Babel for RN projects?

2
do you have babel-polyfill in your dependencies? and installed in your node_modules? - h1b9b

2 Answers

1
votes

yes it was an import of the babel polyfill, but do you know the explanation to this?

it is because you are writing ES6 code but import hasn't been yet totally added to it so polyfill transforms this to CommonJS, interesting isn't it? in the future it is predicted that you wont need it anymore since it will be implemented 100%

0
votes

Ended up being an import of the babelpolyfill module i'd left uncommented-out in the index.js file.

Totally ditzy by me.