Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  153] [ 6]  / answers: 1 / hits: 15684  / 8 Years ago, thu, march 24, 2016, 12:00:00

enter



I'm trying to use gulp-babel so I can start writing some ES6 / ES2015 code inside of my ES5 app.



var gulp          = require('gulp'),
gutil = require('gulp-util'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
sass = require('gulp-ruby-sass'),
streamqueue = require('streamqueue'),
sourcemaps = require('gulp-sourcemaps'),
templateCache = require('gulp-angular-templatecache'),
htmlReplace = require('gulp-html-replace'),
runSequence = require('run-sequence'),
stripDebug = require('gulp-strip-debug'),
del = require('del'),
es = require('event-stream'),
webpack = require('webpack-stream'),
babel = require('gulp-babel'),
browserSync = require('browser-sync').create();


And lower down in my code, here is where the problem lies:



gulp.task('build-min-bundle', function() {
gutil.log(gutil.colors.blue.bold(' Compiled bundle file contains these modules:'));
for (var i=0; i<paths.scripts.length; i++) {
gutil.log(gutil.colors.yellow.bold(' '+paths.scripts[i]));
}
return gulp.src(paths.bundle)
.pipe(stripDebug())
.pipe(concat(dist))
.pipe(babel()) // <--
.pipe(uglify())
.on('error', errorlog)
.pipe(gulp.dest('app/assets/js'));
});


I originally tried this first:



.pipe(babel({
presets: ['es2015']
}))



Argument name clash in strict mode (2774:5)



More From » gulp

 Answers
60

The error isn't in your quoted code, it's on line 2774 of tickertags.bundle.min.js. Babel isn't the problem, Babel is reporting the problem.



In strict mode, this is an error:



function foo(a, a) {
}


Note that a has been used as an argument name twice. That's valid loose code, but not valid strict code. That's what the error message is telling you about.



Here's the error replicated in Babel's REPL.



Here's the error replicated in your browser, if your browser correctly supports strict mode:





use strict;
function foo(a, a) {
}





On Chrome, the error is




Uncaught SyntaxError: Duplicate parameter name not allowed in this context



[#62821] Tuesday, March 22, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
benitoh questions
Sun, Mar 21, 21, 00:00, 3 Years ago
Mon, May 13, 19, 00:00, 5 Years ago
;