3 ms·
When I had an opportunity to make use of import.meta, I was pleasantly surprised because it enabled me to write a "userspace" hot-module-reload policy with hard
by frou_dh 4y ago
When I had an opportunity to make use of import.meta, I was pleasantly surprised because it enabled me to write a "userspace" hot-module-reload policy with hardly any code (for a browser game when developing using Vite: https://vitejs.dev/guide/api-hmr.html https://vitejs.dev/guide/api-hmr.html).
The "keyword followed by a dot?!" aspect that initially felt strange to me isn't that off-the-wall either, because it also exists in the form new.target: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new.target https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- dmitriid 4y agoYes, new.target was cited as a precedent for this decision. Even though new.target itself was such an ugly hack that the spec was specifically coded for new.target alone. So import is: - a keyword that can only exist at top level at the top of the file - except when it looks like a function, but it's not a function and doesn't behave like one - and it's also apparently and object because it has what looks like a property on it IIRC there was a proposal for an Import (or was it System?) that would take care of things like import.meta etc., but it was deemed to complex. Instead we have import()
- WorldMaker 4y ago> and it's also apparently and object because it has what looks like a property on it In JS functions are objects, so this isn't that weird for JS. (For easy example, JQuery alone used this a lot with `$('selector')` and `$.ajax(…)` and all sorts of other things.)
- dmitriid 4y agoYes, but import() isn't a function ;)