gluonjs icon indicating copy to clipboard operation
gluonjs copied to clipboard

es6-modules: replacement for document.currentScript for getting file-relative urls

Open rictic opened this issue 8 years ago • 2 comments

What we're hearing is that import.meta is the leading candidate for replacement of the document.currentScript methods of getting the current file's url. Still stage 2, but from what I hear it's getting pretty wide acceptance and approval.

That's likely the direction we're taking with the polymer modulizer.

rictic avatar Aug 26 '17 04:08 rictic

Thanks for the suggestion. :)

I did look into import.meta and it seems to be basically what we need. The difficulty is that it cannot be polyfilled, so we have to wait until it is implemented absolutely everywhere, or we need some fallback mechanism. It seems to me like it is worth exploring alternative solutions that we can use as fallback in these cases.

ruphin avatar Aug 26 '17 10:08 ruphin

Yeah. It can't be polyfilled, but it can be compiled at the application level (with some configuration). As best as we've been able to figure out, there's no other way to know the file's location at runtime without hard coding assumptions.

rictic avatar Aug 26 '17 19:08 rictic