How to compile ES6 using gulp with support for require()?

Studying the new es6 to es5 generation using babeljs + gulp. Here's my gulpfile. In fact, the crux of the problem - when you use the feature import/export generated code with require(), as I understand it, one of the options which - browserify, but I have not tried to tie it to your gulp file - nothing comes out. Share, plz configs, who as he uses es6.

'use strict';

var gulp = require("gulp");
var sourcemaps = require("gulp-sourcemaps");
var babel = require("gulp-babel");
var concat = require("gulp-concat");
var sequence = require("run-sequence");
var rimraf = require('rimraf');
var watch = require('gulp-watch');
var path = {
 build: {
 dir: 'dist/',
 jsAppfile: 'apps.js'
},
 src: {
 js: 'src/**/*.js'
}
};

gulp.task('clean', function (cb) {
 rimraf(path.build.dir, cb);
});

gulp.task("build", function () {
 return gulp.src(path.src.js)
.pipe(sourcemaps.init())
.pipe(concat(path.build.jsAppfile))
.pipe(babel())
.pipe(sourcemaps.write('maps'))
.pipe(gulp.dest(path.build.dir));
});

gulp.task('watch', function(){
 watch([path.src.js], function(event, cb) {
gulp.start('build');
});
});

gulp.task('default', function() {
 sequence('clean', 'build', 'watch');
});
September 19th 19 at 00:26
2 answers
September 19th 19 at 00:30
Thanks, I'll try a bit later to accomplish your goal. - Jovanny24 commented on September 19th 19 at 00:33
I understand that a little logic will change the config - if I choose all js files in the src/ directory, now I need to take only the main file, which has to be imported all the necessary? - Jovanny24 commented on September 19th 19 at 00:36
: no idea - I did your sources not seen even once. Read about browserify - maybe you and it is not suitable. - Jovanny24 commented on September 19th 19 at 00:39
: And there's no source just before working with es5 I went ahead and glued all the js files from the src folder, and now, as I understand it I need to some main.js import dependence, and browserify already all stick together. This is judging from the above repository, I judge, will be the evening to understand by browserify. - Leola66 commented on September 19th 19 at 00:42
: In short, it's been so long, and this topic lives on crutches, and "folk methods" ... : / - Jovanny24 commented on September 19th 19 at 00:45
September 19th 19 at 00:28
You need 6to5ify module for browserify
I would like to see the real config. As I understand 6to5ify now is babelify. There are examples but they just confuse, I understand that browserify some of their ways to makes concatination, sourcemap and so on, i.e. just add the pipe to my config comes out. - Jovanny24 commented on September 19th 19 at 00:31

Find more questions by tags JavaScript