Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Woah, importmap is a game changer! I didn't know about it until reading this, thanks!


Not yet available on Safari, but still cool!

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sc...


https://github.com/guybedford/es-module-shims has a polyfill.

(But it is fairly large: 53KB raw, 15KB gzipped, 32KB minified, 11KB minified+gzipped. It’s providing a lot of likely-unnecessary functionality. I’d prefer a stripped-down and reworked polyfill that can also be lazily-loaded, controlled by a snippet of at most a few hundred bytes that you can drop into the document, only loading the polyfill in the uncommon case that it’s needed—like how five years ago as part of modernising some of the code of Fastmail’s webmail, I had it fetch and execute core-js before loading the rest iff !Object.values (choosing that as a convenient baseline—see https://www.fastmail.com/blog/using-the-modern-web-platform/... for more details), so that the cost to new browsers of supporting old browsers was a single trivial branch, and maybe fifty bytes in added payload. I dislike polyfills slowing down browsers that don’t need them, by adding undue weight or extra requests.)


There's also https://github.com/systemjs/systemjs if you want more of a ponyfill approach. FWIW bundlers also don't use the browser's functionality to load modules...

It's a bit late to figure out, but I see caveats with dynamic imports in es-module-shims but not SystemJS.


That's going to change when Safari 16.4 comes out - currently in beta: https://developer.apple.com/documentation/safari-release-not...



No Safari support seems like a significant hurdle.


Safari support is enabled with https://github.com/guybedford/es-module-shims


I’m the post author, and I use this same polyfill. I even install it with the same NPM download method I wrote about.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: