babel: babel-preset-es2015 compile class error

Choose one: is this a bug report or feature request?

Input Code

class Test {
    testFun() {
        return 0;
    }
}

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

{
  "babel-preset-es2015": "7.0.0-alpha.10",
}

Expected Behavior

I used babel-preset-es2015 7.0.0-alpha.10 when I compile Test.js compile error “path.get(…).arrowFunctionToExpression is not a function while parsing”

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 35 (19 by maintainers)

Commits related to this issue

Most upvoted comments

This is likely the opposite, you’re using the new preset with an older babel-core.

Ok all the issues seem to be with using an older babel-core and newer preset (or vice-versa), will close.

We’ll need to figure out a way to determine compat with a versioning thing (to throw if it’s not the same or compat to a babel-core version)

You sure that is the issue @hzoo ? I am running same version of both of them, and I am still getting the: path.arrowFunctionToExpression is not a function error.

Even with the same versions, I had to use “function”, instead of “=>” on my test file. That is not doable for my whole codebase.

I don’t have a firm enough grasp of just how peerdeps work, so it’s hard to answer. At the very least, the plugins/presets could absolutely validate the Babel version.

Yeah it should be pinned. Should we be rethinking peerDeps on babel-core? I’m actually surprised it has been working for that long

Using a semver range on something marked alpha is a hugely bad idea

Seems to be a regression from #5677.

Could you please provide the stack trace?