Questions tagged [babeljs]

Babel (formerly 6to5) is a JavaScript compiler. It transforms ES6+/ES2015 code into ES5 code.

Babel (formerly 6to5) is a JavaScript compiler.
It transforms ES6+/ES2015 code into ES5 code.


Important Note about Babel v6

With Babel v6, Babel became a platform for JS code transformations. That means it doesn't include any ES2015 to ES5 transformers by default. This has to be enabled explicitly.

Please see


Resources:

9692 questions
5
votes
2 answers

Difference between anonymous function vs named function as value for an object key

I have compiled JSX to JavaScript using Babel compiler. Here is the piece of code I'm intrigued with. getInitialState: function getInitialState() { //List out different states that ListComponent could possibly have return { showList: true, …
Anvesh Checka
  • 3,787
  • 2
  • 21
  • 28
5
votes
2 answers

Which Babel transformers should I blacklist for a Chrome app?

I'm writing ES6+ code and compiling it with Babel (currently using {stage: 0} as my .babelrc config). So I'm compiling everything right down to ES5. But I'm exlusively targeting Chrome v47+, which supports some ES6+ features natively. Which of the…
callum
  • 34,206
  • 35
  • 106
  • 163
5
votes
2 answers

es6 babelify changes variable name, variable can't be found in inspector

I am using es6 modules in my application, and I am encountering a problem when debugging in my chrome inspector. When I do something like the following in my code: import 'widget' from './widget' class SomeClass { componentDidMount(){ …
5
votes
1 answer

RequireJS + Babel + JSX

I'm trying to invoke in-browser JSX transformations using Babel. I'm loading an AMD JS module in the browser using the following: require(["nbextensions/ht"] function(ext){}); Which eventually imports this "ui" module, which has calls a function to…
ejang
  • 3,982
  • 8
  • 44
  • 70
5
votes
2 answers

How to run babel.transform for react with Nashorn?

I am trying to use babel.transform instead of JSXTranformer for react. ... ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine nashorn = mgr.getEngineByName("nashorn"); nashorn.eval("var process = {env:{}}"); // node-modules expect…
Alexander Arutinyants
  • 1,619
  • 2
  • 23
  • 49
5
votes
1 answer

How to setup Karma + Jasmine to use ES6 modules

I'm a bit stuck on this. I have a complex stack composed of middleman, karma, jasmine, babeljs to build a static website. Considering this is an experiment, I wanted to use ES6 with modules. Everything fine on middleman side, though, I'm having hard…
Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
5
votes
1 answer

Unexpected token at @ error in Aurelia module

When I run an Aurelia app, I get the following error in Chrome. I get the error wherever I have @. For example, @customElement and @bindable gives the error. My config.js looks like below: System.config({ "baseURL": "/", "transpiler": "babel", …
wonderful world
  • 10,969
  • 20
  • 97
  • 194
5
votes
2 answers

How do we avoid boilerplate code in files transpiled by Babel?

For example, if I run babel src --source-maps --out-dir . --modules common on the src folder of my project, it output all the files in ., but each and every file contains things like var _createClass = (function () { function…
trusktr
  • 44,284
  • 53
  • 191
  • 263
5
votes
1 answer

Using require('babel/register') vs. transpiling the code before running

Are there any performance benefits of the latter compared to the former? When I tested it on my own, the time it took for one of my projects to load already transpiled was much shorter than when it uses babel/register. Apart from start-up time…
kpimov
  • 13,632
  • 3
  • 12
  • 18
5
votes
1 answer

babel is exporting "this" as undefined in ember computed property

using ember-cli@0.2.7 and emberjs@1.13.2. Source emberjs model export default DS.Model.extend({ name: DS.attr('string'), displayName : Ember.computed('name', () => { return this.get('name'); }) }); Translated model 'use…
jax
  • 37,735
  • 57
  • 182
  • 278
5
votes
1 answer

Releasing es6 and es5 sources with npm

I am developing two node packages registered with npm, and using es6 syntax. Each package has only one es6 module exporting a single class. package A has no dependencies package B depends on A Class A export default class A {...} Class B import A…
Thomas Roch
  • 1,208
  • 8
  • 19
5
votes
2 answers

Can Babel compile for "node --harmony" instead of ES5?

I am trying to compile a Koa app, and Koa has assertions that check to make sure that I am passing generator functions as middleware. However, I would like to compile my server side code from ES7 using Babel, for consistency with the front end…
Dan Ross
  • 3,596
  • 4
  • 31
  • 60
5
votes
1 answer

`Invalid mapping` error trying to use babel require hook and polyfill with react jsx transpile

I'm trying to use babel for both ES6 and JSX transpilation for mocha tests. Suppose we have test.jsx like this: var React = require("react"); React.createClass({ render: function(){ return (
Hello World
); } }); Running babel…
Chris Jaynes
  • 2,868
  • 30
  • 29
5
votes
2 answers

Compiling ES6 arrow functions to Es5 using Babel.js

While looking into ES6 arrow functions' documentation on Mozilla documentation, I got to know that Arrow functions applies all the rules of strict mode, except one as described in the link var f = () => { 'use strict'; return this}; var g…
Navaneeth
  • 2,555
  • 1
  • 18
  • 38
5
votes
1 answer

Trouble viewing original ES6 source in browser after transpiling w/ Babel

All, I'm using SystemJS with Babel as a transpiler to learn how to generate ES5 code from ES6 on my browser. When I try to view the source using Chrome Dev Tools, I see ES5 code and not my original ES6 code. I'm using the default babelOptions in…
ntilwalli
  • 358
  • 3
  • 9
1 2 3
99
100