babel: ReferenceError: _objectSpread is not defined after update

Bug Report

Current Behavior I’ve updated to 7.5 and have been following the developments with issues that should have been resolved with https://github.com/babel/babel/releases/tag/v7.5.1 however after stripping and reinstalling everything babel-related, I’m still getting this error.

Babel packages @babel/cli: “^7.5.0” @babel/core: “^7.5.0” @babel/helpers: “^7.5.1” @babel/plugin-proposal-object-rest-spread: “^7.5.1” @babel/plugin-transform-runtime: “^7.5.0” @babel/polyfill: “^7.4.4” @babel/preset-env: “^7.5.0” @babel/preset-react: “^7.0.0” babel-eslint: “^10.0.2” babel-jest: “^24.8.0” babel-loader: “^8.0.6” babel-plugin-dynamic-import-node: “^2.3.0” babel-plugin-jsx-remove-data-test-id: “^2.0.0” babel-plugin-transform-class-properties: “^6.24.1” babel-plugin-transform-decorators-legacy: “^1.3.5” babel-plugin-transform-export-extensions: “^6.22.0” babel-plugin-transform-object-rest-spread: “^6.26.0”

Babel Configuration (.babelrc, package.json, cli command)

{
  "env": {
    "test": {
      "plugins": [
        "transform-class-properties",
        "dynamic-import-node",
        "@babel/plugin-transform-runtime"
      ]
    },
    "production": {
      "plugins": ["babel-plugin-jsx-remove-data-test-id"]
    }
  },
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": ["transform-class-properties"]
}

Environment

  • Babel version(s): 7.5.0
  • Node/npm version: 6.5.0
  • OS: Linux Mint Cinnamon
  • Monorepo: yes

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 16
  • Comments: 50 (16 by maintainers)

Commits related to this issue

Most upvoted comments

When using jest, it’s going to request babel 7.1.0, which still causes problems with the spread operator because of #10187. But you can get around it by adding a resolution to your package.json, as in:

"resolutions": {
    "@babel/core": "^7.5.4"
  }

which will force jest into using the newer babel. This seems to fix the problem with jest at least.

I have created https://github.com/babel/babel/issues/10187 which shows the root cause of this issue.

I was having this issue when running tests in Jest, after upgrading babel + plugins.

I found that running yarn-deduplicate && yarn was enough to fix it.

@nicolo-ribaudo @babel/core was mentioned in this thread, so I happened to look at my package.json and I am shocked to see that it was not in there … I added the latest and then upgraded “@babel/plugin-proposal-object-rest-spread”: “7.5.4” and my error is gone. 👍

After I tested, this work correctly when I downgrade to @babel/plugin-proposal-object-rest-spread@7.4.4 and @babel/helpers@7.5.1.

@nicolo-ribaudo here’s my current branch where it’s failing https://github.com/jenniferlynparsons/cuppa-webpack/tree/feature/login-form-validation

I’ve got it narrowed down at the moment to the AuthReducer.js file where I’ve added the “LOGIN_ERRORS” case. The case before that (“USER_LOADING”) is the one that’s failing in the AuthReducers.test.js file. Sorry I can’t get it narrowed down any further than that.

I’ve also noticed that if I remove the “LOGIN_ERRORS” case, the tests pass. There’s no reason that I can see why that would have any effect unless there’s some edge case I’m hitting that I’m unaware of.