Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
karlas opened this issue May 7, 2018 · 15 comments
Closed
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@karlas
Copy link

karlas commented May 7, 2018

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
@babel-bot
Copy link
Collaborator

Hey @karlas! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo
Copy link
Member

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.

@loganfsmyth
Copy link
Member

More specifically, where is your package.json? If the .babelrc is outside the directory containing the package.json, it is now ignored.

@karlas
Copy link
Author

karlas commented May 7, 2018

Yes, it's outside the directory where package.json is. Will this be a definitive change?

@loganfsmyth
Copy link
Member

@karlas Yeah, the assumption now is that .babelrc files are scopes to a package. For broader configuration of many packages in a single repo, we now expect a babel.config.js file that exports the config to be in the project root working directory. Sounds like that is probably what you'd want.

@karlas
Copy link
Author

karlas commented May 8, 2018

Ok! Will try. Thanks!

@karlas
Copy link
Author

karlas commented May 8, 2018

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?

@Buslowicz
Copy link

Just for clarification: are we no longer able to use .babelrc file? I have the exact same issue as above, here are my .babelrc and @babel/* versions:

{
  "ignore": [
    "node_nodules/**/*"
  ],
  "presets": [
    [
      "@babel/preset-env",
      {
        "modules": false
      }
    ]
  ],
  "plugins": [
    "@babel/external-helpers",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-proposal-object-rest-spread"
  ]
}
{
  "scripts": {
    "rollup": "rollup -c rollup.config.js"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    "@babel/cli": "7.0.0-beta.44",
    "@babel/core": "7.0.0-beta.44",
    "@babel/plugin-external-helpers": "7.0.0-beta.44",
    "@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.44",
    "@babel/plugin-syntax-dynamic-import": "7.0.0-beta.44",
    "@babel/preset-env": "7.0.0-beta.44",
    ...
    "rollup": "^0.58.2",
    "rollup-plugin-babel": "^4.0.0-beta.4",
    "rollup-plugin-node-resolve": "^3.3.0"
  }
}

@karlas
Copy link
Author

karlas commented May 22, 2018

Ok I finally could fix it, by adding --config-file './functions/src/babel.config.js' to the npm script, resulting:

babel 'functions/src' --config-file './functions/src/babel.config.js' --out-dir 'functions/bundle' --copy-files --ignore 'functions/src/node_modules'

Note i had to add the ./before the route, without it it didn't work

@karlas karlas closed this as completed May 22, 2018
@ajhaupt7
Copy link

@karlas I think @loganfsmyth was saying by default babel looks for a babel.config.js in the project root directory, so rather than putting it at ./functions/src/babel.config.js, you would put it at ./babel.config.js. I'm setting up a project for firebase cloud functions (as it looks like you are ;-)) and that works without having to specify the config file

@rifler
Copy link

rifler commented Jun 1, 2018

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

@felippepuhle
Copy link

thanks @nicolo-ribaudo

@geminiyellow
Copy link

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

@JamesTheHacker
Copy link

JamesTheHacker commented Sep 9, 2018

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.

@Sin360
Copy link

Sin360 commented Sep 19, 2018

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"
  }
}

pmuens added a commit to serverless/components that referenced this issue Oct 2, 2018
eahefnawy pushed a commit to serverless/components that referenced this issue Oct 19, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 19, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Dec 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests