Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

support node 7.6 #166

Closed
graingert opened this issue Feb 23, 2017 · 10 comments
Closed

support node 7.6 #166

graingert opened this issue Feb 23, 2017 · 10 comments

Comments

@graingert
Copy link

depends on compat-table/compat-table#1033

@yavorsky
Copy link
Member

yavorsky commented Feb 24, 2017

@graingert Good point! We could add it right after merge.

@hulkish
Copy link

hulkish commented Feb 27, 2017

I just wanted to add.. that I hope this automatically excludes transform-async-to-generator. Currently, that is not the case for [email protected]. 😞

@hulkish
Copy link

hulkish commented Mar 3, 2017

@hzoo does this include #166 (comment)?

@noinkling
Copy link

noinkling commented Mar 3, 2017

@hulkish Yes. Debug output:

Using plugins:
  transform-exponentiation-operator {"node":7.6}
  syntax-trailing-function-commas {"node":7.6}

No transform-async-to-generator.

@batjko
Copy link

batjko commented Mar 15, 2017

I'm not sure I'm using this correctly.
I have just updated to node 7.7, and am trying to get the native async/await to work.
I still have to use babel for modules, so I am using the env preset.

However, I keep getting the regenerator error:

node -v: v7.7.3

index.js:

require('babel-register')
require('./sandpit')

sandpit.js

import axios from 'axios'

async function printNorris(category) {
  const norris = await axios.get(`https://api.chucknorris.io/jokes/random?category=${category}`)
  console.log(norris.data.value)
}
printNorris('dev')

.babelrc:

{
  "presets": ["env"]
}

node index.js -> Output:

  var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
                               ^
ReferenceError: regeneratorRuntime is not defined
    at D:\git\XXX\sandpit.js:4:32
    at Object.<anonymous> (D:\git\XXX\sandpit.js:29:2)
    at Module._compile (module.js:571:32)
    at loader (D:\git\XXX\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (D:\git\XXX\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)

I thought this should work just fine now, without babel having to transform the async/await constructs. No?

@noinkling
Copy link

noinkling commented Mar 15, 2017

@batjko Check the examples in the readme, your .babelrc should look something like:

{
  "presets": [
    ["env", {
      "targets": {
        "node": "current"
      }
    }]
  ]
}

If you don't include targets it will just transpile everything ES2015+

@batjko
Copy link

batjko commented Mar 15, 2017

Ha! It does the trick, @noinkling.
I did read the README, but it wasn't clear to me that this was necessary. I assume there is some incompatibility with the default env preset?

Thanks for your quick response!

@hzoo
Copy link
Member

hzoo commented Mar 15, 2017

default env preset

If you don't pass any options it acts the same as preset-latest which compiles everything. You have to tell the preset what you support or it doesn't know what to not compile, make sense?

@batjko
Copy link

batjko commented Mar 16, 2017

You have to tell the preset what you support or it doesn't know what to not compile, make sense?

Yup, makes now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants