I just have a simple question cant get in any place, heve been googling for it all morning. There is no much info about traceur and when there is is not so clear, at least to me.
How should be implemented the ES6 modules when im transpiling with traceur a single output file and using it in the browser with traceur-runtime? import and export keeps getting Unexpected token.
I am using gulp-traceur and tried already all the modules options //'commonjs' //'amd', 'commonjs', 'instantiate', 'inline', 'register'.
One doubt I have is that I keep finding answers about commonjs, but my idea of using ES6 modules is to have differents sources and then from the main import them and have all this result compiled in one single file (what i mean is that I dont need async loading of the modules in the browser)
Here is the gulp task
gulp.task('scripts', function() {
del.sync(['bin/js/main.min.js']);
del.sync(['bin/js/main.min.js.map']);
gulp.src(["./src/app/init.js", "./src/app/elements/circle.js", "./src/app/app.js"])
.pipe(sourcemaps.init())
.pipe(traceur({modules : 'inline', sourceMaps: 'inline', experimental: "true"})) //'commonjs' //'amd', 'commonjs', 'instantiate', 'inline', 'register'
.on('error', errorParser)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(uglify({mangle: true})).on('error', errorParser)
.pipe(concat('main.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('bin/js'))
.pipe(livereload({ auto: true }));
});
The unexpected token comes from app when importing
import Circle from './elements/circle';
or
import * as Circle from './elements/circle.js';
(Tried several ways)
Also from circle.js when exporting
export default Circle;
or export Circle;
(also tried several ways)