7

I understand the ES6 modules specification, the question is about its support. AFAIK, there are no browsers that implement this natively (see Browser compatibility here). Got a couple of questions about this:

  • ES6 modules is an ES6 feature, obviously. When I look at kangax compatibility table, I don't see such row (for ES6 modules) at all, why is that? It's a ES6 feature afterall...
  • hence, the only way to use ES6 right now is to use a build tool, such as babel, browserify or any other aternative, right?
  • how are the modules gonna be fetched, when they're natively supported - as async AJAX calls from the browser?
ducin
  • 25,621
  • 41
  • 157
  • 256

2 Answers2

3

ES6 modules is an ES6 feature, obviously. When I look at kangax compatibility table, I don't see such row (for ES6 modules) at all, why is that?

There's an issue being discussed on kangax's github.

the only way to use ES6 right now is to use a build tool, such as babel, browserify or any other aternative, right?

No. There is also a polyfill by Guy Bedford at http://github.com/ModuleLoader/browser-es-module-loader.

And there's already the preview release of Edge that implements it natively.

how are the modules gonna be fetched, when they're natively supported - as async AJAX calls from the browser?

Yes but not exactly: they will be fetched when the are used for the first time, by a call to an object (a function or a property) on the imported library.

Supersharp
  • 29,002
  • 9
  • 92
  • 134
  • 1
    thanks! you proved that it **is** posible to answer such question on SO :) perfect! PS does the polyfill by Guy Bredford simulate exactly how should ES6 modules work, when they're natively supported (in terms of execution, not syntax)? – ducin Sep 26 '16 at 08:08
  • @ducin I'm not sure but I don't think it's possible. I guess it works more like ajax async. This could be ckecked with Dev Tools. – Supersharp Sep 26 '16 at 08:19
1

Native modules are available in the following versions of browsers:

  • Safari 10.1
  • Chrome Canary 60 – behind the Experimental Web Platform flag in chrome:flags.
  • Firefox 54 – behind the dom.moduleScripts.enabled setting in about:config.
  • Edge 15 – behind the Experimental JavaScript Features setting in about:flags.

source

Vanuan
  • 31,770
  • 10
  • 98
  • 102