Git Product home page Git Product logo

babel-preset-es2015-node5's People

Contributors

alekseykulikov avatar andrepolischuk avatar chalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

davej pana iq-scm

babel-preset-es2015-node5's Issues

Transpiling breaks Express routes

I'm using this preset to transpile code that worked well with Babel 5. It breaks when Express tries to mount the routes, in a way that suggests the transpiled code does not sit well with the Express Router:

/Users/project/node_modules/express/lib/router/index.js:458
      throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
      ^

TypeError: Router.use() requires middleware function but got a Object
    at Function.use (/Users/project/node_modules/express/lib/router/index.js:458:13)
    at EventEmitter.<anonymous> (/Users/project/node_modules/express/lib/application.js:219:21)
    at Array.forEach (native)
    at EventEmitter.use (/Users/project/node_modules/express/lib/application.js:216:7)
    at Object.<anonymous> (/Users/project/lib/app.js:26:5)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)

The line in the app.js file referred to is:

app.use('/', routes);

And the routes object is a file that uses Express.Router to mount some simple GET/POST routes. As said, same file worked great before I upgraded to Babel 6.

Update:

My routes file looks (roughly) like this:

import express from 'express';
var router = express.Router();

router.get('/', (req, res) => {
  //code
});
...
//more routes
...
export default router;

If I change the last line to module.exports = router; everything works, so I think it may have something to do with transpiling export default?

Usage of es2015-node5 with async functions

What is the correct config for using async/await with es2015-node5? I'm using babel 6 on node 5 and having trouble with async funcitons. Here is my code:

import { getId } from '../utils';
...
const userId = await getId(...);

The transpiled code is as follow:

var _utils = require('../utils');
...
const userId = yield (0, _utils.getId)(...);

.babelrc:

{
    "presets": ["stage-0", "es2015-node5"]
}

.package.json:

"dependencies": {
    "babel-polyfill": "^6.2.0",
    "babel-preset-es2015-node5": "^1.1.0",
    "babel-preset-stage-0": "^6.1.18",
...

It gives me error (0 , _utils.getId) is not a function

In my entry js file I already called import 'babel-polyfill';. What am I missing to make it work?

Include babel-plugin-transform-es2015-shorthand-properties

While node5 does support shorthand properties, the following case fail in node and not in Chrome:

function get() {}
function set() {}

// This line fails.
const obj = { get, set };

I think we should include babel-plugin-transform-es2015-shorthand-properties to remedy this until node ships with a version of v8 that has fixed this.

I want to income parameters 'react' and 'es2015' into babel.

I write my webpack.config.js like this :

{test: /.js$/, loaders: ['react-hot', 'babel?presets[]=es2015'], exclude: /node_modules/}

I want and presets ['react'] into my config, How should I write my config file ?

I need your help . thank you !

Include babel-plugin-transform-es2015-block-scoping

The V8 in node 5 does not support ES2015 compatible block scoping for let and const.

For example, in node 5.2, this input:

const a = {a: 'b', c: 'd', e: 'f'}
for (const key in a) { console.log(key, a[key]); }

produces this output:

a b
a b
a b

Whereas according to the spec it should output:

a b
c d
e f

This is fixed by including babel-plugin-transform-es2015-block-scoping in the preset.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.