I had the same problem in front of me ... As Qantas mentioned in the comments, Babel (previously 6to5) will convert the syntax, but it will not load the module or polyfill.
I found that the simplest workflow uses browserify with gulp . This will take care of transpilation, adding polylines, picking, minimizing and generating source maps in one hit. This question has a pretty nice example: Gulp + brown + 6to5 + source maps .
In this version minifixes and policies are added. An example for your case will look like this:
let gulp = require('gulp'); let browserify = require('browserify'); let babelify = require('babelify'); let util = require('gulp-util'); let buffer = require('vinyl-buffer'); let source = require('vinyl-source-stream'); let uglify = require('gulp-uglify'); let sourcemaps = require('gulp-sourcemaps'); gulp.task('build:demo', () => { browserify('./demo/app.js', { debug: true }) .add(require.resolve('babel-polyfill/dist/polyfill.min.js')) .transform(babelify.configure({ presets: ['es2015', 'es2016', 'stage-0', 'stage-3'] })) .bundle() .on('error', util.log.bind(util, 'Browserify Error')) .pipe(source('demo.js')) .pipe(buffer()) .pipe(sourcemaps.init({ loadMaps: true })) .pipe(uglify({ mangle: false })) .pipe(sourcemaps.write('./')) .pipe(gulp.dest('./demo')); }); gulp.task('default', ['build:demo']);
It is important that uglify set mangle to false; it really doesn't look good with converted code.
If you do not have all the dependencies, you can create the package.json file and verify that the following packages are defined in the dependencies object:
"devDependencies": { "babel-polyfill": "^6.13.0", "babel-preset-es2015": "^6.13.0", "babel-preset-es2016": "^6.11.0", "babel-preset-stage-0": "^6.5.0", "babel-preset-stage-3": "^6.11.0", "babelify": "^7.3.0", "browserify": "^13.1.0", "gulp": "^3.9.0", "gulp-sourcemaps": "^1.6.0", "gulp-uglify": "^2.0.0", "gulp-util": "^3.0.0", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0" }
Most of them will not work if installed using -g , so think about yourself: P
Then just run npm install to install all the dependencies, and gulp to run the default task and pass all your code.
Your other files look good, you have the right idea with importing at the beginning of each file and exporting your default values :) If you want some examples of babelified ES6 to be in the wild, I have several GitHub projects that can help .