Error Babel JS babel-preset-php

I just tried the new Babel babel-preset-php ( https://gitlab.com/kornelski/babel-preset-php#php7-to-es7-syntax-translator ). I did everything in the README file, I set the preset with npm i -S babel-preset-php. Then I created a file .babelrcwith the following contents:

{
    "presets": ["php"]
}

Installed cli using npm i -g babel-cli. Then I created a simple PHP file that contains only a simple function:

<?php

function addCalculator($x, $y)
{
    return $x + $y;
}

And he tried to start the transpiler with babel number.php -o file.js. But I get an error when running the script:

/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/lib/plugins.js:6
        Identifier(p) {
                  ^
SyntaxError: Unexpected token ( (While processing preset: "/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/index.js")
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/index.js:1:79)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)

I'm not that experience with nodejs and npm, so any idea on what could happen?

+6
source share
2

: , , . PHP. . PHP- .

+2

, PHP. , babel-preset-php:

return {
    visitor: {
        Identifier(p) { // This is the invalid line
            if (p.node.name != 'Exception' || p.scope.hasBinding("Exception")) {
                return;
            }

, ECMAScript 2015. , , , , Javascript ES2015.

node babel .

+2

All Articles