@@ -859,6 +859,8 @@ pp.parseExportAllDeclaration = function(node, exports) {
859859 this . expectContextual ( "from" )
860860 if ( this . type !== tt . string ) this . unexpected ( )
861861 node . source = this . parseExprAtom ( )
862+ if ( this . options . ecmaVersion >= 16 )
863+ node . attributes = this . parseWithClause ( )
862864 this . semicolon ( )
863865 return this . finishNode ( node , "ExportAllDeclaration" )
864866}
@@ -889,6 +891,8 @@ pp.parseExport = function(node, exports) {
889891 if ( this . eatContextual ( "from" ) ) {
890892 if ( this . type !== tt . string ) this . unexpected ( )
891893 node . source = this . parseExprAtom ( )
894+ if ( this . options . ecmaVersion >= 16 )
895+ node . attributes = this . parseWithClause ( )
892896 } else {
893897 for ( let spec of node . specifiers ) {
894898 // check for keywords used as local names
@@ -1017,6 +1021,8 @@ pp.parseImport = function(node) {
10171021 this . expectContextual ( "from" )
10181022 node . source = this . type === tt . string ? this . parseExprAtom ( ) : this . unexpected ( )
10191023 }
1024+ if ( this . options . ecmaVersion >= 16 )
1025+ node . attributes = this . parseWithClause ( )
10201026 this . semicolon ( )
10211027 return this . finishNode ( node , "ImportDeclaration" )
10221028}
@@ -1077,6 +1083,41 @@ pp.parseImportSpecifiers = function() {
10771083 return nodes
10781084}
10791085
1086+ pp . parseWithClause = function ( ) {
1087+ let nodes = [ ]
1088+ if ( ! this . eat ( tt . _with ) ) {
1089+ return nodes
1090+ }
1091+ this . expect ( tt . braceL )
1092+ const attributeKeys = { }
1093+ let first = true
1094+ while ( ! this . eat ( tt . braceR ) ) {
1095+ if ( ! first ) {
1096+ this . expect ( tt . comma )
1097+ if ( this . afterTrailingComma ( tt . braceR ) ) break
1098+ } else first = false
1099+
1100+ const attr = this . parseImportAttribute ( )
1101+ const keyName = attr . key . type === "Identifier" ? attr . key . name : attr . key . value
1102+ if ( hasOwn ( attributeKeys , keyName ) )
1103+ this . raiseRecoverable ( attr . key . start , "Duplicate attribute key '" + keyName + "'" )
1104+ attributeKeys [ keyName ] = true
1105+ nodes . push ( attr )
1106+ }
1107+ return nodes
1108+ }
1109+
1110+ pp . parseImportAttribute = function ( ) {
1111+ const node = this . startNode ( )
1112+ node . key = this . type === tt . string ? this . parseExprAtom ( ) : this . parseIdent ( this . options . allowReserved !== "never" )
1113+ this . expect ( tt . colon )
1114+ if ( this . type !== tt . string ) {
1115+ this . unexpected ( )
1116+ }
1117+ node . value = this . parseExprAtom ( )
1118+ return this . finishNode ( node , "ImportAttribute" )
1119+ }
1120+
10801121pp . parseModuleExportName = function ( ) {
10811122 if ( this . options . ecmaVersion >= 13 && this . type === tt . string ) {
10821123 const stringLiteral = this . parseLiteral ( this . value )
0 commit comments