News for hackers. Stuff that matters.
Re:JavaScript Modules by phleet on Wednesday July 02, 2014 @11:45AM (#7977642)
Can someone explain to me the migration path towards ES6 and syntax like this? This isn't syntactically valid ES5, so is there a reasonable path to making the browsers run ES6 directly?

If I just include it in a <script> tag directly, it'll throw syntax errors in any non-es6 compliant browser. So I'd have the transpile, and send down the es5 version of the code.

But if I'm transpiling, what's the point? I still have a build step, so why use ES6 over another compile-to-js language? The eventual promise, that years and years and years from now, all the non-es6 compliant browser will be dead, so I can send down the es6 code directly?

Re:JavaScript Modules by ripter on Wednesday July 02, 2014 @12:40PM (#7977975)
script supports a new type, module.

    <script type="module">
        // loads the 'q' export from 'mymodule.js' in the same path as the page
        import { q } from 'mymodule';

        new q(); // -> 'this is an es6 class!'
    </script>
You can use it today with things like : https://github.com/ModuleLoader/es6-module-loader