Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

es6 modules native support

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?
like image 254
ducin Avatar asked Aug 25 '16 11:08

ducin


Video Answer


2 Answers

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.

like image 121
Supersharp Avatar answered Sep 28 '22 23:09

Supersharp


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

like image 40
Vanuan Avatar answered Sep 28 '22 21:09

Vanuan