Babel file is copied without being transformed

Babel is a transformation framework. Pre-6.x, it enabled certain transformations by default, but with the increased usage of Node versions which natively support many ES6 features, it has become much more important that things be configurable. By default, Babel 6.x does not perform any transformations. You need to tell it what transformations to run:

npm install babel-preset-env

and run

babel --presets env proxy.js --out-file proxified.js

or create a .babelrc file containing

{
    "presets": [
        "env"
    ]
}

and run it just like you were before.

env in this case is a preset which basically says to compile all standard ES* behavior to ES5. If you are using Node versions that support some ES6, you may want to consider doing

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

to tell the preset to only process things that are not supported by your Node version. You can also include browser versions in your targets if you need browser support.

Leave a Comment