Skip to content

Latest commit

 

History

History
241 lines (165 loc) · 8.67 KB

Spec.md

File metadata and controls

241 lines (165 loc) · 8.67 KB

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 del illustrate 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.


15 ECMAScript Language: Scripts and Modules

15.2 Modules

15.2.1 Module Semantics

15.2.1.15 Source Text Module Records

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

15.2.3 Exports

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 VariableStatement
  • export Declaration
  • export 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

15.2.3.2 Static Semantics: BoundNames

ExportDeclaration :

  • export * FromClause ;
  • export ExportClause FromClause ;
  • export ExportClause ;
  • export ExportFromClause FromClause ;
  • export NamedExports ;
  1. Return a new empty List.

15.2.3.3 Static Semantics: ExportedBindings

ExportDeclaration :

  • export ExportClause FromClause ;
  • export * FromClause ;
  • export ExportFromClause FromClause ;
  1. Return a new empty List.

15.2.3.4 Static Semantics: ExportedNames

ExportDeclaration : export * FromClause ;

  1. Return a new empty List.

ExportDeclaration :

  • export ExportClause FromClause ;
  • export ExportClause ;
  1. Return the ExportedNames of ExportClause.

ExportDeclaration : export ExportFromClause FromClause ;

  1. Return the ExportedNames of ExportFromClause.

ExportFromClause : *

  1. Return a new empty List.

ExportFromClause : ExportedDefaultBinding , NameSpaceExport

  1. Let names be the ExportedNames of ExportedDefaultBinding.
  2. Append to names the elements of the ExportedNames of NameSpaceExport.
  3. Return names.

ExportFromClause : ExportedDefaultBinding , NamedExports

  1. Let names be the ExportedNames of ExportedDefaultBinding.
  2. Append to names the elements of the ExportedNames of NamedExports.
  3. Return names.

15.2.3.5 Static Semantics: ExportEntries

ExportDeclaration : export * FromClause ;

  1. Let module be the sole element of ModuleRequests of FromClause.
  2. Let entry be the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: null }.
  3. Return a new List containing entry.

ExportDeclaration : export ExportClause FromClause ;

  1. Let module be the sole element of ModuleRequests of FromClause.
  2. Return ExportEntriesForModule of ExportClause with argument module.

ExportDeclaration : export ExportFromClause FromClause ;

  1. Let module be the sole element of ModuleRequests of FromClause.
  2. Return ExportEntriesForModule of ExportFromClause with argument module.

15.2.3.6 Static Semantics: ExportEntriesForModule

ExportFromClause : *

  1. Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: null }.

ExportFromClause : ExportedDefaultBinding , NameSpaceExport

  1. Let entries be ExportEntriesForModule of ExportedDefaultBinding with argument module.
  2. Append to entries the elements of the ExportEntriesForModule of NameSpaceExport with argument module.
  3. Return entries.

ExportFromClause : ExportedDefaultBinding , NamedExports

  1. Let entries be ExportEntriesForModule of ExportedDefaultBinding with argument module.
  2. Append to entries the elements of the ExportEntriesForModule of NamedExports with argument module.
  3. Return entries.

ExportedDefaultBinding : IdentifierName

  1. Let exportName be the StringValue of IdentifierName.
  2. Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "default", [[LocalName]]: null, [[ExportName]]: exportName }.

NameSpaceExport : * as IdentifierName

  1. Let exportName be the StringValue of IdentifierName.
  2. Return a new List containing the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: null, [[ExportName]]: exportName }.

15.2.3.7 Static Semantics: IsConstantDeclaration

ExportDeclaration :

  • export * FromClause ;
  • export ExportClause FromClause ;
  • export ExportClause ;
  • export ExportFromClause FromClause ;
  • export NamedExports ;
  • export default AssignmentExpression ;
  1. Return false.

15.2.3.8 Static Semantics: LexicallyScopedDeclarations

ExportDeclaration :

  • export * FromClause ;
  • export ExportClause FromClause ;
  • export ExportClause ;
  • export ExportFromClause FromClause ;
  • export NamedExports ;
  • export VariableStatement
  1. Return a new empty List.

15.2.3.9 Static Semantics: ModuleRequests

ExportDeclaration :

  • export * FromClause ;
  • export ExportClause FromClause ;
  • export ExportFromClause FromClause ;
  1. Return the ModuleRequests of FromClause.

15.2.3.11 Runtime Semantics: Evaluation

ExportDeclaration :

  • export * FromClause ;
  • export ExportClause FromClause ;
  • export ExportClause ;
  • export ExportFromClause FromClause ;
  • export NamedExports ;
  1. Return NormalCompletion(empty).

Annex A (informative) Grammar Summary

A.5 Scripts and Modules

Note: See alterations in 15.2.3.