facebook/regenerator

Property name expected type of string but got null [Error]

jeremytenjo opened this issue · 8 comments

Following code produces the error:

const hello = async () => {
  const he = { ll: '2' }
  const { ll } = he
}

babel config

module.exports = {
  presets: [
    [
      require('@babel/preset-env'),
      {
        targets: 'defaults, not ie <= 11, not edge > 0, not IE_Mob 11',
        modules: false
      }
    ],
    require('@babel/preset-react')
  ],
  plugins: [
    require('react-hot-loader/babel'),
    require('@babel/plugin-transform-regenerator'),
    require('@babel/plugin-syntax-dynamic-import'),
    require('@babel/plugin-syntax-throw-expressions'),
    require('@babel/plugin-transform-runtime'),
    require('babel-plugin-styled-components')
  ],
  env: {
    production: {
      plugins: [require('babel-plugin-transform-react-remove-prop-types')]
    }
  }
}

package.json

  "dependencies": {
    "@babel/core": "^7.9.0",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-syntax-throw-expressions": "^7.8.3",
    "@babel/plugin-transform-regenerator": "^7.8.7",
    "@babel/plugin-transform-runtime": "^7.9.0",
    "@babel/preset-env": "^7.9.0",
    "@babel/preset-react": "^7.9.4",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^25.1.0",
    "babel-loader": "^8.1.0",
    "babel-plugin-styled-components": "^1.10.7",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
    "react-hot-loader": "^4.12.20"
  },

node version v12.13.1

Thanks

More context #390

@tenjojeremy / @liuliangsir All the browsers with destructuring support also support generators. What is the use case for regenerator when you are not transpiling destructuring?

@nicolo-ribaudo I removed this package and my app still works, turn out I wasn't using it correctly but don't need it. I no longer need the fix but it seems other people do.

I removed this package and my app still works

@tenjojeremy , which package? Sadly, I have been running into the issue above for some time. Here is a minimal reproducible example.

I removed require('@babel/plugin-transform-regenerator')

@liuliangsir Does your targets support destructuring?

  • Yes -> Then they also support generators, so you can remove @babel/plugin-transform-regenerator
  • No -> Then you need to add @babel/plugin-transform-destructuring

#391 (comment) solves the issue

@liuliangsir Does your targets support destructuring?

  • Yes -> Then they also support generators, so you can remove @babel/plugin-transform-regenerator
  • No -> Then you need to add @babel/plugin-transform-destructuring

@nicolo-ribaudo if targets support destructuring, why is this error reported when add @babel/plugin-transform-regenerator

Because this plugin assumes that destructuring has been compiled. What's your use case for compiling generators but not destructuring?