Microsoft Edge supports ES6 modules
blogs.windows.com
blogs.windows.com
1. No way to dynamically import a module (the article explains this).
2. All imports must be relative or absolute urls, so either ./foo.js or /foo.js or http://example.com/foo.js
This means you can't npm install lodash and import the string "lodash".
3. All imports must include the file extension (.js). So even if you set up a server route for /lodash it would break as soon as one of lodash's imports didn't use .js (or it imports another package). This is assuming lodash is written with import/export; it's not so it wouldn't work at all.
4. Until http2 comes around, this is probably not something you want to ship to production (unless you have a small app with only have a handful of scripts being imported), so bundlers are here to stay for a while.
It might be possible to work around 1, 2, and 3 using Service Workers, I wrote about this a while ago: https://matthewphillips.info/posts/loading-app-with-script-m...
Or, .mjs [1].
[1] https://github.com/nodejs/node-eps/blob/master/002-es6-modul...
I was worried this was short for "Microsoft JS", thanks for the link.
For example, you might depend on "foo" and "bar". "foo" also depends on "bar", but it needs version 1 and you need version 2. In this case, setting paths for "bar" won't work, the paths are different for each parent.
The loader spec provides a hook "resolve" that allows you to work around this, just wanted to point out that configuration alone wouldn't be enough.
It's also worth noting that the Loader spec doesn't have a real urgency to it. What I mean is that likely browsers will implement script type=module first, give it some time to brew, and then pull in things from whatwg/loader over time. In the meantime we'll want solutions that do allow us to use script type=module and still have modern workflows we are used to.
[1] https://blog.cloudflare.com/cloudflares-impact-on-the-http-2...
That users aren't connecting to http/2 web sites is no indicator that http/2 is not available.
If 47% of all CloudFlare users are not connecting via HTTP/2 (even though it is supported server side), I believe it means that those users do not have client side support (or are behind a proxy, etc. which doesn't allow it).
At the end, if someone is thinking about making a website which would be much slower for non-HTTP/2 users then right now it means around 47% of their users.
There again, I could also poke fun at Flexbox and http://w3cmemes.tumblr.com/post/26637660418/believe-it-or-no..., given we all thought it was stable. :)
Perhaps the "bleeding edge" is a touch too extreme for what ultimately was wanted, but certainly something much closer to other browsers than where IE had been before.
Modules give you a certain degree of namespacing, which is nice. Compiling down to a tar to be served to a Service Worker is undoubtedly easier than the mangling needed to remove the modules.
But bundling will still probably be faster and will probably continue to be a mainstay of production web apps, just like minification already is.
I think you meant executing the actual JS. Finding the imports requires parsing the file, and imports can be anywhere in the file as long as they're at the top level.
If someone then misuses document.write the token stream has to be thrown out and things have to be retokenized, but that's rare in practice. The tradeoff is better accuracy of the preloader and not having to go through the text twice unless someone is misusing document.write.
From a developer perspective, producing the only the dependency graph is still going to be faster and need less overall IO than building a bundle. You can get a sense of it today with jspm dep-cache versus jspm bundle times.
In one project I worked on, we had 3 bundles: - early load (inside the head tag) - deferred load secondary (after body tag, for the other site pages) - deferred load primary (after the body tag, for the 'hot' pages of the site) With a optimal http/2.0 setup, we wouldn't need to make these never fully optimal bundles.
try {
eval('"use strict"; import "jquery";');
} catch (e) {
// No imports.
}
but I wouldn't really recommend it.If you want to use all the ES6 features, no single modern browser implements them all (Webkit is still lacking on modules) and so you will need to use a collection of polyfills.
Not surprised by this, they made it pretty clear at their dev summit that ES6 was a priority.
(function() {
___MODULE["foo"] = foo
})();
function require(m) {return ___MODULE[m]}Of course it will be at least 10 years before people can safely require Edge and another 5 years before that version of Edge current enough to support modules.
Remember: IE11 will be supported with Windows 8, 8.1 and 10 until at least 2020 and the enterprise version of Windows 10 never gets feature updates and thus never an updated Edge.
I doubt many LTSB browsers browse the internet (beyond perhaps having a website open in kiosk mode disallowing entering other websites), and even if they do, not with IE.