babel-preset-react-native-stage-0 icon indicating copy to clipboard operation
babel-preset-react-native-stage-0 copied to clipboard

plugin/preset files are not allowed to export objects only functions

Open The-Code-Monkey opened this issue 5 years ago • 13 comments

image

this is happening on a brand new project what am i doing wrong im new to native

The-Code-Monkey avatar Jul 10 '18 13:07 The-Code-Monkey

My error message:

error: bundling failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /path/to/project/node_modules/babel-preset-react-native-stage-0/decorator-support.js

babel-preset-react-native-stage-0's code:

decorator-support.js

module.exports = {
  presets: [require('babel-preset-react-native')],
  plugins: [
    require('babel-plugin-transform-decorators-legacy').default,
    require('babel-plugin-transform-do-expressions'),
    require('babel-plugin-transform-function-bind'),
    require('babel-plugin-transform-class-constructor-call'),
    require('babel-plugin-transform-export-extensions'),
    require('babel-plugin-syntax-trailing-function-commas'),
    require('babel-plugin-transform-exponentiation-operator'),
  ]
}

Babel handbook document - making your own preset

module.exports = {
  presets: [
    require("babel-preset-es2015"),
    require("babel-preset-react")
  ],
  plugins: [
    require("babel-plugin-transform-flow-strip-types")
  ]
};

It IS the same, I'm confused why it won't build.

rankun203 avatar Jul 11 '18 02:07 rankun203

I'm guessing the latest version of babel-preset-react-native-stage-0 is doing something that its not supposed to.

The-Code-Monkey avatar Jul 11 '18 07:07 The-Code-Monkey

I've downgraded to "react-native": "0.55.0" and it worked.

rankun203 avatar Jul 11 '18 07:07 rankun203

ah so its the latest version of rn or did they upgrade their version of babel preset and broke it?

The-Code-Monkey avatar Jul 11 '18 07:07 The-Code-Monkey

thanks for letting me know

The-Code-Monkey avatar Jul 11 '18 07:07 The-Code-Monkey

@skevy WIll you update this preset to babel 7?

lorenc-tomasz avatar Jul 12 '18 20:07 lorenc-tomasz

I have the same issue, I think is probably related to Babel Issue 6808

ortegoncarlos avatar Jul 14 '18 18:07 ortegoncarlos

Unless your React Native project uses experimental Javascript, you can resolve this problem by installing babel-preset-react-native@5 and replacing "babel-preset-react-native-stage-0/decorator-support" with "babel-preset-react-native" in the project's .babelrc file.

fagerbua avatar Aug 01 '18 06:08 fagerbua

Any solution for experimental Javascript?

lorenc-tomasz avatar Aug 01 '18 08:08 lorenc-tomasz

@lorenc-tomasz Adding the plugins you need directly to your .babelrc file ought to work, as long as they're Babel 7 compatible. See the list of transformation plugins in Babel 7.

fagerbua avatar Aug 01 '18 10:08 fagerbua

Some solution right now?

Danjavia avatar Nov 12 '18 22:11 Danjavia

It's almost the end of January'19, any progress?

artus9033 avatar Jan 20 '19 20:01 artus9033

@fagerbua 's solution worked for me!! And I prefer it to @rankun203 's answer, as dealing with changing react-native's version especially when you are so far into the project, can lead to just so much work and configurations.

Kaybarax avatar May 02 '19 08:05 Kaybarax