Note: This document is written as a delta against the ES6 RC4 specification. Headers illustrate the location in the specification. The use of ins and
delillustrate addition and removal to existing sections. Shaded blocks followed by content indicates an existing portion of content to be replaced by the followed content. Unadorned content is new or contextually unalterned. Omitted content should be assumed irrelevant to this proposal unless otherwise noted.
Table 42 (Informative) — Export Forms Mappings to ExportEntry Records
Export Statement Form | [[ExportName]] | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
---|---|---|---|---|
export var v; |
"v" |
null | null | "v" |
export default function f(){}; |
"default" |
null | null | "f" |
export default function(){}; |
"default" |
null | null | "*default*" |
export default 42; |
"default" |
null | null | "*default*" |
export {x}; |
"x" |
null | null | "x" |
export {v as x}; |
"x" |
null | null | "v" |
export v from "mod"; |
"v" |
"mod" |
"default" |
null |
export * as ns from "mod"; |
"ns" |
"mod" |
"*" |
null |
export {x} from "mod"; |
"x" |
"mod" |
"x" |
null |
export {v as x} from "mod"; |
"x" |
"mod" |
"v" |
null |
export * from "mod"; |
null | "mod" |
"*" |
null |
Syntax
Note: ExportClause has been renamed to NamedExports for clarity and symmetry with NamedImports. This rename should be reflected throughout the entire ECMA spec document, which this delta document does not fully cover.
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportClause;
export
ExportFromClause FromClause;
export
NamedExports;
export
VariableStatementexport
Declarationexport
default
HoistableDeclaration[Default]export
default
ClassDeclaration[Default]export
default
[lookahead ∉ {function
,class
,from
}] AssignmentExpression[In];
ExportFromClause :
*
- ExportedDefaultBinding
- NameSpaceExport
- NamedExports
- ExportedDefaultBinding
,
NameSpaceExport - ExportedDefaultBinding
,
NamedExports
ExportedDefaultBinding :
- IdentifierName
NameSpaceExport :
*
as
IdentifierName
ExportClauseNamedExports :
{
}
{
ExportsList}
{
ExportsList,
}
ExportsList :
- ExportSpecifier
- ExportsList
,
ExportSpecifier
ExportSpecifier :
- IdentifierName
- IdentifierName
as
IdentifierName
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportClause;
export
ExportFromClause FromClause;
export
NamedExports;
- Return a new empty List.
ExportDeclaration :
export
ExportClause FromClause;
export
*
FromClause;
export
ExportFromClause FromClause;
- Return a new empty List.
ExportDeclaration :
export
*
FromClause;
- Return a new empty List.
ExportDeclaration :
export
ExportClause FromClause;
export
ExportClause;
- Return the ExportedNames of ExportClause.
ExportDeclaration : export
ExportFromClause FromClause ;
- Return the ExportedNames of ExportFromClause.
ExportFromClause : *
- Return a new empty List.
ExportFromClause : ExportedDefaultBinding ,
NameSpaceExport
- Let names be the ExportedNames of ExportedDefaultBinding.
- Append to names the elements of the ExportedNames of NameSpaceExport.
- Return names.
ExportFromClause : ExportedDefaultBinding ,
NamedExports
- Let names be the ExportedNames of ExportedDefaultBinding.
- Append to names the elements of the ExportedNames of NamedExports.
- Return names.
ExportDeclaration :
export
*
FromClause;
- Let module be the sole element of ModuleRequests of FromClause.
- Let entry be the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: null }.
- Return a new List containing entry.
ExportDeclaration :
export
ExportClause FromClause;
- Let module be the sole element of ModuleRequests of FromClause.
- Return ExportEntriesForModule of ExportClause with argument module.
ExportDeclaration : export
ExportFromClause FromClause ;
- Let module be the sole element of ModuleRequests of FromClause.
- Return ExportEntriesForModule of ExportFromClause with argument module.
ExportFromClause : *
- Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: null }.
ExportFromClause : ExportedDefaultBinding ,
NameSpaceExport
- Let entries be ExportEntriesForModule of ExportedDefaultBinding with argument module.
- Append to entries the elements of the ExportEntriesForModule of NameSpaceExport with argument module.
- Return entries.
ExportFromClause : ExportedDefaultBinding ,
NamedExports
- Let entries be ExportEntriesForModule of ExportedDefaultBinding with argument module.
- Append to entries the elements of the ExportEntriesForModule of NamedExports with argument module.
- Return entries.
ExportedDefaultBinding : IdentifierName
- Let exportName be the StringValue of IdentifierName.
- Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "default", [[LocalName]]: null, [[ExportName]]: exportName }.
NameSpaceExport : *
as
IdentifierName
- Let exportName be the StringValue of IdentifierName.
- Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: exportName }.
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportClause;
export
ExportFromClause FromClause;
export
NamedExports;
export
default
AssignmentExpression;
- Return false.
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportClause;
export
ExportFromClause FromClause;
export
NamedExports;
export
VariableStatement
- Return a new empty List.
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportFromClause FromClause;
- Return the ModuleRequests of FromClause.
ExportDeclaration :
export
*
FromClause;
export
ExportClause FromClause;
export
ExportClause;
export
ExportFromClause FromClause;
export
NamedExports;
- Return NormalCompletion(empty).
Note: See alterations in 15.2.3.