1

I'm trying a very simple test with the babel-cli

After installing it I made a file with the contents:

test.js

class Point {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    static distance(a, b) {
        const dx = a.x - b.x;
        const dy = a.y - b.y;

        return Math.sqrt(dx*dx + dy*dy);
    }
}

const p1 = new Point(5, 5);
const p2 = new Point(10, 10);

console.log(Point.distance(p1, p2));

Next I ran the command to transform it...

$ babel test.js

I expected to see the "transformed ES5" javascript, but it just spits out the exact same stuff, line for line, no transformation.

How do you use Babel to convert this into ES5 javascript code?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
kidcapital
  • 5,064
  • 9
  • 46
  • 68
  • This question is asked every day. Please use the search or at least browse the `babeljs` tag. – Felix Kling Nov 12 '15 at 16:59
  • 1
    sorry. when i typed in the question nothing relevant came up, so i still posted. also googling "babel not working" "babel not compiling" did not yield stack overflow results. – kidcapital Nov 12 '15 at 17:01
  • First result: [`[babeljs] not compiling`](http://stackoverflow.com/search?q=%5Bbabeljs%5D+not+compiling). – Felix Kling Nov 12 '15 at 17:06
  • 1. that first result is mine, 2. i used google search not SO search. i will use SO search next time... – kidcapital Nov 12 '15 at 17:10
  • :D you got me there... yeah, SO search can be quite useful if you can narrow down the search space with tags! At least others are able to find the duplicate via this query now... – Felix Kling Nov 12 '15 at 17:11

0 Answers0