Does this imply <module src=""> ?

On Sat, Nov 16, 2013 at 12:30 AM, David Herman <dher...@mozilla.com> wrote:

> On Nov 16, 2013, at 3:32 AM, John Barton <johnjbar...@google.com> wrote:
>
> > Could someone help me understand why two goals for parsing JS is a good
> thing?
>
> Hm, it sounds like you've assumed a conclusion already. Let me try to
> explain anyway.
>
> Scripts are for synchronous loading and evaluation; modules are for
> asynchronous loading and evaluation. The former is not allowed to import,
> which triggers I/O. The latter is allowed to import. There was always going
> to have to be a syntactic split.
>
> But there's more. I'll be explaining at this week's TC39 meeting some more
> details about the intended model for browser integration. In short,
> declarative code based on modules will use the <module> tag (or <script
> type="module">, which will mean the same thing and allows polyfilling
> today). This is better than <script async>, which was a hopeless idea. This
> also works beautifully for fulfilling the promise of 1JS: a new, better
> initial environment in which to run top-level application code without
> requiring versioning.
>
>     <module>
>       var x = 12;             // local to this module, not exported on
> global object
>       import $ from "jquery"; // asynchronous dependency, NBD
>       '$' in this             // nope, because all globals are scoped to
> this module
>       let y = 13;             // yep, let works great because modules are
> strict
>     </module>
>
> Same number of characters as <script>, better semantics, better global
> environment, better language.
>
> If you're not excited about ES6 yet, get excited. :)
>
> Dave
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
- Matthew Robb
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to