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
- Use babel-core 7.5+ in new RN Apps Summary: We are running into some problems with the spread operator. The solution is to ask for a newer minimum babel version. See https://github.com/babel/babel/i... — committed to facebook/react-native by cpojer 5 years ago
- Workaround #10179 in proposal-object-rest-spread — committed to nicolo-ribaudo/babel by nicolo-ribaudo 5 years ago
- Workaround #10179 in proposal-object-rest-spread (#10200) — committed to babel/babel by nicolo-ribaudo 5 years ago
- Work around babel error https://github.com/babel/babel/issues/10179 — committed to itaylor/thunk-centric-redux by itaylor 5 years ago
- Workaround #10179 in proposal-object-rest-spread (#10200) — committed to AdamRamberg/babel by nicolo-ribaudo 5 years ago
- Fix `...` (spread operator) missing error. Babel seems to need a specific package to support the `...` operator for now. See: https://github.com/babel/babel/issues/10179#issuecomment-510254948 npm i... — committed to Automattic/woocommerce-payments by reykjalin 5 years ago
- feat: Update dependencies https://github.com/babel/babel/issues/10179 — committed to rocket-hangar/rocket-scripts by deleted user 5 years ago
- Fix `...` (spread operator) missing error. Babel seems to need a specific package to support the `...` operator for now. See: https://github.com/babel/babel/issues/10179#issuecomment-510254948 npm i... — committed to Automattic/woocommerce-payments by reykjalin 5 years ago
- Use fresh data for transactions (#139) * Add reducer with some basic actions The reducer does define some actions, but never produces a different state. * Add function to initalize the data st... — committed to Automattic/woocommerce-payments by reykjalin 5 years ago
- Fix `...` (spread operator) missing error. Babel seems to need a specific package to support the `...` operator for now. See: https://github.com/babel/babel/issues/10179#issuecomment-510254948 npm i... — committed to Automattic/woocommerce-payments by reykjalin 5 years ago
- Fix transactions ui snapshot for fresh data (#177) * Add packages necessary to run tests For some reason jest can't find '@wordpress/api-fetch' unless it's installed. Even though the test doesn't... — committed to Automattic/woocommerce-payments by reykjalin 5 years ago
When using
jest
, it’s going to request babel7.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: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.
Repl demo: https://babeljs.io/repl/version/7.4.4#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=MYewdgzgLgBCCuUAOiDC4BmBLA5jAvDAN4wB05CyiMAvgNwBQoksz2ehJ5pOApmLwBOAQwA26MO1p0gA&debug=false&forceAllTransforms=true&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=&prettier=false&targets=&version=7.1.6&externalPlugins=%40babel%2Fplugin-proposal-object-rest-spread%407.5.3
It appears to be a problem when using an old version of
@babel/core
with a new version of@babel/plugin-proposal-object-rest-spread
. As a workaround, you can update@babel/core
to^7.5.0
.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.