Module Loader Polyfill

Check the console in your browser developer tools! This code is currently loaded in the page:

  <script src="../node_modules/traceur/bin/traceur.js"></script>
  <script src="../dist/es6-module-loader-dev.js"></script>
  <script type="module">
    import { hello } from 'test1.js';
    console.log(hello); // -> world

    // es6 syntax
    var a, b;
    [a, b] = [1, 2];
    console.log(a); // 1
  </script>
    

Click on the button below and this function will be run:

  <script>
    function buttonClick() {
      // dynamic loading API
      System.import('test2.js').then(function(module) {
        new module.Foo();
      });
    }
  </script>
    

Note that if you click on the button again, a new Foo module will be created, but 'test2' will not be reloaded.