@@ -194,7 +194,7 @@ function margeImport(
194194 usedIds . add ( name ) ;
195195 }
196196 } else {
197- const node = findNamedImport ( spec . imported . name ) ;
197+ const node = findNamedImport ( getName ( spec . imported ) ) ;
198198 if ( node ) {
199199 localNames [ spec . local . name ] = node . spec . local . name ;
200200 } else {
@@ -207,7 +207,7 @@ function margeImport(
207207 type : "ImportSpecifier" ,
208208 imported : {
209209 type : "Identifier" ,
210- name : spec . imported . name ,
210+ name : getName ( spec . imported ) ,
211211 } ,
212212 local : {
213213 type : "Identifier" ,
@@ -260,7 +260,8 @@ function margeImport(
260260 for ( const node of iterateImport ( ) ) {
261261 const spec = node . specifiers . find (
262262 ( spec ) : spec is ESTree . ImportSpecifier =>
263- spec . type === "ImportSpecifier" && spec . imported . name === imported ,
263+ spec . type === "ImportSpecifier" &&
264+ getName ( spec . imported ) === imported ,
264265 ) ;
265266 if ( spec ) {
266267 return { decl : node , spec } ;
@@ -309,7 +310,7 @@ function margeRequire(
309310 } else if ( spec . type === "ImportDefaultSpecifier" ) {
310311 importedName = "default" ;
311312 } else {
312- importedName = spec . imported . name ;
313+ importedName = getName ( spec . imported ) ;
313314 }
314315 const preferName : string = spec . local . name ;
315316 if ( requireNode . type === "Identifier" ) {
@@ -456,3 +457,7 @@ function resolveName(name: string, usedIds: Set<string>) {
456457 }
457458 return resolved ;
458459}
460+
461+ function getName ( node : ESTree . Identifier | ESTree . Literal ) : string {
462+ return node . type === "Identifier" ? node . name : String ( node . value ) ;
463+ }
0 commit comments