babel: @babel/plugin-proposal-object-rest-spread not being detected at beta.46

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

.babelrc

{
  "presets": [
    ["@babel/env", {
      "targets": { "node": "6.11.5" }
    }]
  ],
  "plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

CLI Command

babel 'functions/src' --out-dir 'functions/bundle' --copy-files --ignore 'functions/src/node_modules'

Expected Behavior

Files are correctly built, as it did with beta.44

Current Behavior

With beta.46, following error arises:

Error: SyntaxError: functions/src/common/getLocations.js: Support for the experimental syntax 'objectRestSpread' isn't currently enabled (77:19):

  75 |         if (key === 'viewport'){
  76 |           const { northeast, southwest } = geometry.viewport;
> 77 |           return {...prev, bounds : {
     |                   ^
  78 |             ne : {
  79 |               lat : northeast.lat,
  80 |               lng : northeast.lng

Add @babel/plugin-proposal-object-rest-spread (https://git.io/vb4Ss) to the 'plugins' section of your Babel config to enable transformation.
    at /Users/karlas/project/node_modules/@babel/cli/lib/babel/dir.js:185:22
    at /Users/karlas/project/node_modules/@babel/cli/lib/babel/dir.js:148:23
    at /Users/karlas/project/node_modules/@babel/cli/lib/babel/dir.js:120:23
    at /Users/karlas/project/node_modules/@babel/cli/lib/babel/dir.js:82:23
    at /Users/karlas/project/node_modules/@babel/cli/lib/babel/util.js:126:16
    at runAsync (/Users/karlas/project/node_modules/@babel/core/lib/transformation/index.js:37:12)
    at /Users/karlas/project/node_modules/@babel/core/lib/transform-file.js:56:36
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

Possible Solution

Can’t help…

Context

Just transpiling about 20 files to be used on Firebase Functions

Your Environment

software version(s)
Babel 7.0.0-beta.46
node 8.11.1
npm 5.6.0
yarn 1.6.0
Operating System macOS High Sierra

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

.babelrc.js in prj root worked until beta.44, but doesn’t in 45 and above

Mmm i can´t get it work. What i made:

  1. Rename functions/src/.babelrcto functions/src/babel.config.js
  2. Add the module.exports to this file, resulting:
module.exports = {
  "presets": [
    ["@babel/env", {
      "targets": { "node": "6.11.5" }
    }]
  ],
  "plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

Am I doing something wrong?

oh… why babel.config.js , looks so bad.

2 hours wasted pulling my hair out with this one. This should probably be in big bold letters at the head of the repo 🤣 It’s going to trip a lot of people up. Renaming to babel.config.js and exporting works fine.

Can you try to rename babel.config.js and module.export the configuration? We changed how config loading works and it is causing a bunch of problems.

Same for me, it was a lot of pain for me to upgrade babel version and make everything work. After a lot of searches, I renamed .babelrc to babel.config.js et voila !

{
  "devDependencies": {
    "@babel/cli": "^7.1.0",
    "@babel/core": "^7.1.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-transform-async-to-generator": "^7.1.0",
    "@babel/preset-env": "^7.1.0",
    "babel-loader": "^8.0.2"
  }
}