javascript - gulp+babel: running twice, generating broken js code -


i'm new in gulp. i'm using watch , babel plugins auto-transpile es2015+ javascript code.

my problem appears run twice , resulting transpiled code broken. see further below mean twice.

if run directly babel using command below, generated es5 code babel correct , watch mode working fine:

babel ./scripts -d ./www/scripts -w

however, when running under gulp, generated code begins with:

define([], function () { define([...], function () { ... code ... 

when should begin with:

define([...], function(){ ... code ... 

this happens files, both on initial run , afterwards when watching. watch mode per ce works, files updated modify them.

how should proceed generates correct es5 code again ?

thank in advance answers.

relevant part of gulpfile.js:

const gulp = require('gulp'); const watch = require('gulp-watch'); const plumber = require('gulp-plumber');  gulp.task('babel', function(){ const fs = require('fs'); const babel = require('gulp-babel'); const babelrc = json.parse(fs.readfilesync('.babelrc', 'utf8')); return watch('scripts/**/*.js', { ignoreinitial: false }) .pipe(plumber()) .pipe(babel(babelrc)) .pipe(plumber.stop()) .pipe(gulp.dest('www/scripts/')) }); 

here .babelrc

{ "presets": ["env"], "plugins": [ "babel-plugin-transform-async-generator-functions", "babel-plugin-transform-es2015-modules-amd" ] } 

this part of package.json might relevant (the rest of don't think so):

  "browserslist": [     "last 2 versions",     "ie>=11"   ], 


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -