3 ms·
Please no. Write standard modules. Serve standard modules to modern browsers, optionally bundling to modules for production. Bundle to non-modules for legacy br
by spankalee 8y ago
Please no. Write standard modules. Serve standard modules to modern browsers, optionally bundling to modules for production. Bundle to non-modules for legacy browsers.
Then we can all eventually move forward from this mess of non-standard module formats and loaders.
- asdkhadsj 8y agoWhat are "standard modules" for modern browser? I don't typically frontend dev these days, so I'm likely a bit out of the loop. The way I typically thought of dependencies with browsers was to bundle them all together. Is there some new solution to this problem?
- sephware 8y agoThey’re still mainly bundlers for now, such as webpack. But browsers are slowly adopting first class modules which has already been solidified by the spec afaik.
- mhd 8y agoProbably using the ES2015 import syntax[1], which allows you to dynamically load modules. I have my doubts whether your average medium+ sized JS app will be that dynamically, so you'll probably end up slurping a whole lot o' module at startup. And without tree-shaking, more stuff to download and digest. [1]https://caniuse.com/#feat=es6-module-dynamic-import https://caniuse.com/#feat=es6-module-dynamic-import
- spankalee 8y agoYou can bundle modules together so you don't have a ton of downloads, but the basic module graph will at least be loadable. WebPackaging will also help in the future.
- crescentfresh 8y agoOne thing that really sours me in esm is that this is possible (fictional main.js): import Vue from 'vue' import jQuery from 'jquery' global.jQuery = jQuery // to get the next line to work import Bootstrap from 'bootstrap' import 'bootstrap/dist/css/bootstrap.css' Then my head explodes. Why would importing a .css file from my JavaScript ever be a thing supported by any tooling. What is that line trying to communicate? What does it even mean to my current scope? (hint: nothing) import became a giant "do something cool on this line" that maybe the tooling you're using knows how to translate via (say) a webpack loader. For anyone wondering, that line gets translated to the browser dynamically including css on the page.
- spankalee 8y agoImporting CSS is not supported, at least yet.
- dang 8y agoIt's fine to raise a concern or ask a question about it, but please don't be snarky about it. That's against the rules, both for Show HNs and for the site as a whole. https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- spankalee 8y agoHonest question - where was the snark? Am I not allowed to think the current situation is a mess?
- dang 8y agoResponding to someone's work with "Please no" seems snarky to me. Certainly it's rude—especially in a Show HN thread, which is all about someone sharing their own work. https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html