Babel Compilation: Preventing Direct Copy
In the given code snippet, Babel is unable to transform the source file into a compiled output. Instead, it merely copies the original file. This occurs because Babel 6.x requires explicit configuration to specify the desired transformations.
To resolve this issue, install the babel-preset-env package via npm. This preset enables the compilation of all standard ES* behavior to ES5. Then, use the following command:
babel --presets env proxy.js --out-file proxified.js
Alternatively, create a .babelrc file with the following configuration:
{ "presets": ["env"] }
Running Babel with this configuration will apply the ES5 compilation, resolving the direct copy issue.
The above is the detailed content of Why is Babel Copying My Source File Instead of Compiling It?. For more information, please follow other related articles on the PHP Chinese website!