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

Object rest parameters throw exceptions on parsing (related to upgrade to core-js@3) #9713

Closed
ehmicky opened this issue Mar 20, 2019 · 6 comments
Assignees
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Comments

@ehmicky
Copy link

ehmicky commented Mar 20, 2019

Bug Report

Current Behavior
I've just upgraded to core-js@3 and Babel 7.4.0. Object rest parameters are throwing errors when being parsed.

Input Code

test.js:

function test({ ...others }) {}

In a terminal:

$ babel test.js
TypeError: Cannot destructure property `name` of 'undefined' or 'null'.
    at resolveKey (/home/ether/Desktop/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js:74:9)
    at PluginPass.ObjectPattern (/home/ether/Desktop/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js:204:21)
    at newFn (/home/ether/Desktop/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/home/ether/Desktop/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/home/ether/Desktop/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/home/ether/Desktop/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (/home/ether/Desktop/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitMultiple (/home/ether/Desktop/node_modules/@babel/traverse/lib/context.js:85:17)
    at TraversalContext.visit (/home/ether/Desktop/node_modules/@babel/traverse/lib/context.js:144:19)
    at Function.traverse.node (/home/ether/Desktop/node_modules/@babel/traverse/lib/index.js:94:17)

Expected behavior/code
No exception should be thrown.

Babel Configuration (.babelrc)

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: { node: '8.10.0' },
        useBuiltIns: 'usage',
        corejs: 3,
      },
    ],
  ],
  plugins: ['@babel/plugin-transform-runtime'],
}

Environment

$ npm ls @babel/cli @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime core-js
desktop@1.0.0 /home/ether/Desktop
├── @babel/cli@7.2.3 
├── @babel/core@7.4.0 
├── @babel/plugin-transform-runtime@7.4.0 
├─┬ @babel/preset-env@7.4.1 
│ └─┬ core-js-compat@3.0.0
│   └── core-js@3.0.0  deduped
├── @babel/runtime@7.4.0 
└── core-js@3.0.0 
  • Node/npm version: node v11.12.0, npm 6.9.0
  • OS: Ubuntu 18.10
  • Monorepo: no
  • How you are using Babel: cli
@babel-bot
Copy link
Collaborator

Hey @ehmicky! 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

As a side note, you need to use corejs: 3 instead of corejs: 'core-js@3'.

@ehmicky
Copy link
Author

ehmicky commented Mar 20, 2019

@nicolo-ribaudo thanks for the tip, I was actually a little confused about this. I got the wrong option from this StackOverflow question.

However setting it to 3 still reproduces the issue. I've updated my initial post accordingly.

@zloirock
Copy link
Member

I'll try to fix it after some hours.

zloirock added a commit that referenced this issue Mar 20, 2019
@zloirock zloirock mentioned this issue Mar 20, 2019
@zloirock
Copy link
Member

Fixed.

@ehmicky
Copy link
Author

ehmicky commented Mar 21, 2019

This works! Thanks!

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants