I'm using ES6 modules transpiled to ES5 with traceur.
Transpilation is done via grunt + grunt-traceur
Traceur allows you to pick which module handler to use: its own, AMD, commonJS or inline.
I have tried most of them, but none seems to to work. Why?
TestClass.js
export default class TestClass {
constructor() {
alert('test');
}
}
Main.js
import TestClass from './TestClass';
var test = new TestClass();
Gruntfile.js (extract)
traceur: {
options: {
experimental: true,
blockBinding: true,
modules: 'amd'
}
}
index.html (extract)
<script src="js/vendor/traceur-runtime.js"></script>
<script src="js/vendor/require.js"></script>
<script defer async src="js/compiled/Main.js"></script>
Error given
Uncaught Error: Mismatched anonymous define() module: function ($__0) {
It seems that there are issues with the grunt plugin, but even using an older version doesn't seem to help.
Code was adapted from an article.