I am trying to convert the ES6 code to simple JS, using babel in gulp. Running the below code I am getting [Error in Plugin "gulp-babel"] with Message: [Plugin/Preset files are not allowed to export objects, only functions.]
var gulp = require('gulp');
var babel = require('gulp-babel');
gulp.task('scripts',function(){
return gulp.src(['src/scripts/app.js'])
.pipe(babel({presets:['es2015']}))
.pipe(gulp.dest('build/scripts/'))
});
src/scripts/app.js
const hello = (name) => {
return `hello ${name}`;
};
Guiding me to convert the ES6 code to vanilla JS would be most appreciated.
You're probably using Babel 7, and your preset is not compatible with it. You should install and use { presets: ["@babel/preset-env"] }
.