-
Notifications
You must be signed in to change notification settings - Fork 47
import default operator #37
Comments
This was briefly discussed in committee and the feeling was that the additional complexity of having these compound contextual keywords was not worth the few characters saved. |
Personally I do not want to introduce it immediately in this proposal. (It means that I would like to introduce another draft for that if we think we should introduce it) So it is not in a hurry. :) However, the above reason is not convincing to me. I do not think that the purpose of this |
In my opinion, yes, both are about saving characters. The difference is in the complexity tradeoff in exchange for saving those characters. When you already have forms of the form My thinking is that |
Thanks so much!!
Personally, I do not agree with this. ES provides the one special representative binding named
Right. But fortunately, the both
But it is reasonable to me. If we think However it also raises the different question. Can we use this await importDefault("../map.js", referencingScriptOrModule()) edit: Oops. I forgot to mention to static import.
Yeah, but it lacks the dynamic features... |
Plz do not laugh. There is a keyword which already semantically assumes we are creating the object: "new" To make it even more attractive, it is shimmable in case of the need to have runtime distinction between |
That's a great question. Note that you can still wrap it if you want, but not in a shared library. So e.g. at the top of your module you could do function importDefault(x) {
return import(x).then(ns => ns.default);
}
That would be an interesting idea worth exploring, IMO. Fortunately we've reserved the second argument so we can do that.
Yes, that's largely tracked as whatwg/html#1013. @sashafirsov I can't tell how what you're proposing is related to this thread. |
Yeah, but it's a bit unfortunate... but,
If we can do that thing, we can alleviate the situation. Like, function importDefault(x) {
return import(modifyBasedOnSomeScript(x), someScript).then(ns => ns.default);
}
Great! I've just commented on that issue about the script in worker module script :) |
Another issue is with tree shaking: contrary to Would it not be possible to add a second argument, like |
It may be beyond the current proposal, but I've just received some feedback. (BG: dynamic-import is now implemented in WebKit nightly).
In the static import syntax. we have 3 forms:
import * as namespace
,import { named }
, andimport deafult
.On the other hand, the current dynamic-import proposal always resolves the result promise with the namespace object.
By using this object and existing ES syntax, we can write the code that is similar to the second
named
form.However, for the third case, we need to write a bit storage code like this.
or
In the static import syntax, we have the
import default
syntax separately while we can write the named import syntax like the following.This
default
export/import mechanism encouraged modules to export the one representativedefault
export and helped the developer to just use the default exported one instead of specifying the exported binding names.So here, I would like to discuss about introducing the similar thing to the dynamic import. Like,
The text was updated successfully, but these errors were encountered: