es6 modules native support
Asked Answered
G

2

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?
Gamber answered 25/8, 2016 at 11:40 Comment(2)
The first question is unanswerable, especially here on SO…Bulldoze
I would recommend using Webpack in combination with Babel. Webpack will answer second and third question.Thunderous
B
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.

Berlin answered 25/9, 2016 at 14:31 Comment(2)
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)?Gamber
@Gamber 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.Berlin
C
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

Chlo answered 3/5, 2017 at 16:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.