This proposal adds a new form of "export from" which exports another module's default export as an exported name of another, filling a use case similar to the use cases for existing "export from" forms.
See the proposal repository for motivations and more information.
This proposal is closely related to the export ns from proposal.
This spec proposal is written as a diff against the existing ECMAScript specification.
Export Statement Form | [[ExportName]] | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
---|---|---|---|---|
export var v;
|
"v"
|
|
|
"v"
|
export default function f(){}
|
"default"
|
|
|
"f"
|
export default function(){}
|
"default"
|
|
|
"*default*"
|
export default 42;
|
"default"
|
|
|
"*default*"
|
export {x};
|
"x"
|
|
|
"x"
|
export {v as x};
|
"x"
|
|
|
"v"
|
export {x} from "mod";
|
"x"
|
"mod"
|
"x"
|
|
export {v as x} from "mod";
|
"x"
|
"mod"
|
"v"
|
|
export * from "mod";
|
|
"mod"
|
"*"
|
|
export v from "mod";
|
|
"mod"
|
"default"
|
"v"
|
from
to the lookahead after export default
allows for the
disambiguation of export default from "mod"
, which is the proposed syntactic form for
exporting "mod"
's default export as this module's default export, from export default from
,
which is the potentially confusing export of a local named variable from
."*"
, [[LocalName]]: With parameter module.