ES6 module syntax – done?
There was discussion about using this
for exposing metadata about the module. For example (pure speculation):
this.address; // location of the current module
this.name; // name of the current module
this.metadata; // object with metadata generated during the loading lifecycle
this.loader // maybe? reference to the loader that actually loaded this module
Was just going through updating @esdiscuss when I noticed nobody really answered this thread. Which is lame.
The meeting notes at 1 are hard to interpret given that the slides are still MIA (Dave?). But essentially, import-into-namespace syntax is now import * as x from "y"
, replacing the previous module x from "y"
.
There was then discussion of how to get module metadata, with Dave's initial proposal per his slides being this
(as Juan shows). However, we eventually arrived at the idea of
import { name, url } from this module;
(with this module
being bikesheddable, but everyone more or less liked that.) As the notes show, you could also do e.g. import * as me from this module
and then use me.name
and so on.
Thanks, Domenic. Very helpful!
Just for posterity sake, since I got tripped up here…
import .. from this module
did not make it into ES6. It may come in later, in that form or some other.
There was then discussion of how to get module metadata, with Dave's initial proposal per his slides being this (as Juan shows). However, we eventually arrived at the idea of
import { name, url } from this module;
Would it make more sense to add additional meta properties in ES7 for import/export metadata?
ie.
export.name // name of the current module
export.address // location of the current module
export.metadata // object with metadata generated during the loading lifecycle
export.loader // maybe? reference to the loader that actually loaded this module
that is correct.
Sent from my iPhone
yes, we just don't know yet, we have to think about it. there is already a good discussion happening about the loader shim we plan to provide, etc. look into the loader repo.
Sent from my iPhone
I haven’t seen any mention of
import * as foo
in the meeting notes, so I’m assuming that the ES6 module syntax is basically done. Right? Except for the “import-into-namespace syntax”, of course. As an aside, I’m really glad thatthis
won’t be used here (which would have resulted in yet another thing one has to learn aboutthis
).