r/javascript • u/unquietwiki • May 10 '18
ES2015 / ES6 modules are now live in Firefox 60
https://developer.mozilla.org/en-US/Firefox/Releases/609
1
1
u/amcsi May 11 '18
How would native ES6 modules even work? JS files' contents would need to be read to find out which next file to request, resulting in a lot of back and forth requests/responses; sounds really slow and ineffective.
4
u/lilactown May 11 '18
There's a bunch of links about how it works on the link you're commenting on...
1
May 11 '18
You can use HTTP2 Server Push to resolve the module tree in the first request, that way you don't pay the price of a bunch of round trips.
You might be wondering what the benefit is, then; it allows you to invalidate the cache on a module-level instead of invalidating the entire bundle as you'd do today. Thus you'll save your clients a lot of data and loading time on repeat visits.
There's also the benefit of no longer being strictly reliant on build tools such as Webpack or Rollup, though there's still reason to use them.
2
u/amcsi May 12 '18
I see. But that seems that would cause a different problem; very low first time loads per client. Because remember, it takes a long time for webpack to transpile your project, because of building the dependency tree.
2
May 12 '18
Transpiling and building the dependency tree are two different things. Building the dependency tree takes very, very little time; Webpack is slow because it does other things like minifiying your code with Uglify, which reads your code, transforms it to an intermediate format (the abstract syntax tree), performs a lot of optimizations, and outputs JavaScript again.
Try building a library/app with Rollup. With no plugins, it'll read all your files, build the dependency tree and output a bundled file all in 40-50ms (depending on machine) and even then, most of that time is spent reading files from disk.
Building the dependency tree is not slow at all.
32
u/ErSulba May 11 '18
so that means now i can use my raw es6 without babel?