问题
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)
回答1:
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
来源:https://stackoverflow.com/questions/36203233/using-gulp-babel-and-getting-argument-name-clash-in-strict-mode